Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ea8f2a72
Commit
ea8f2a72
authored
Feb 27, 2020
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests following changes to EndpointRequest
See gh-20329
parent
cdae79da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
31 deletions
+51
-31
EndpointRequest.java
...uate/autoconfigure/security/reactive/EndpointRequest.java
+32
-27
EndpointRequest.java
...tuate/autoconfigure/security/servlet/EndpointRequest.java
+4
-4
ApplicationContextServerWebExchangeMatcher.java
.../reactive/ApplicationContextServerWebExchangeMatcher.java
+15
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java
View file @
ea8f2a72
...
@@ -115,12 +115,41 @@ public final class EndpointRequest {
...
@@ -115,12 +115,41 @@ public final class EndpointRequest {
return
new
LinksServerWebExchangeMatcher
();
return
new
LinksServerWebExchangeMatcher
();
}
}
/**
* Base class for supported request matchers.
*/
private
abstract
static
class
AbstractWebExchangeMatcher
<
T
>
extends
ApplicationContextServerWebExchangeMatcher
<
T
>
{
private
ManagementPortType
managementPortType
;
AbstractWebExchangeMatcher
(
Class
<?
extends
T
>
contextClass
)
{
super
(
contextClass
);
}
@Override
protected
boolean
ignoreApplicationContext
(
ApplicationContext
applicationContext
)
{
if
(
this
.
managementPortType
==
null
)
{
this
.
managementPortType
=
ManagementPortType
.
get
(
applicationContext
.
getEnvironment
());
}
if
(
this
.
managementPortType
==
ManagementPortType
.
DIFFERENT
)
{
if
(
applicationContext
.
getParent
()
==
null
)
{
return
true
;
}
String
managementContextId
=
applicationContext
.
getParent
().
getId
()
+
":management"
;
if
(!
managementContextId
.
equals
(
applicationContext
.
getId
()))
{
return
true
;
}
}
return
false
;
}
}
/**
/**
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator
* endpoints}.
* endpoints}.
*/
*/
public
static
final
class
EndpointServerWebExchangeMatcher
public
static
final
class
EndpointServerWebExchangeMatcher
extends
AbstractWebExchangeMatcher
<
PathMappedEndpoints
>
{
extends
ApplicationContextServerWebExchangeMatcher
<
PathMappedEndpoints
>
{
private
final
List
<
Object
>
includes
;
private
final
List
<
Object
>
includes
;
...
@@ -225,36 +254,15 @@ public final class EndpointRequest {
...
@@ -225,36 +254,15 @@ public final class EndpointRequest {
@Override
@Override
protected
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
PathMappedEndpoints
>
context
)
{
protected
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
PathMappedEndpoints
>
context
)
{
if
(!
isManagementContext
(
exchange
))
{
return
MatchResult
.
notMatch
();
}
return
this
.
delegate
.
matches
(
exchange
);
return
this
.
delegate
.
matches
(
exchange
);
}
}
static
boolean
isManagementContext
(
ServerWebExchange
exchange
)
{
ApplicationContext
applicationContext
=
exchange
.
getApplicationContext
();
if
(
managementPortType
==
null
)
{
managementPortType
=
ManagementPortType
.
get
(
applicationContext
.
getEnvironment
());
}
if
(
managementPortType
==
ManagementPortType
.
DIFFERENT
)
{
if
(
applicationContext
.
getParent
()
==
null
)
{
return
false
;
}
String
managementContextId
=
applicationContext
.
getParent
().
getId
()
+
":management"
;
if
(!
managementContextId
.
equals
(
applicationContext
.
getId
()))
{
return
false
;
}
}
return
true
;
}
}
}
/**
/**
* The {@link ServerWebExchangeMatcher} used to match against the links endpoint.
* The {@link ServerWebExchangeMatcher} used to match against the links endpoint.
*/
*/
public
static
final
class
LinksServerWebExchangeMatcher
public
static
final
class
LinksServerWebExchangeMatcher
extends
AbstractWebExchangeMatcher
<
WebEndpointProperties
>
{
extends
ApplicationContextServerWebExchangeMatcher
<
WebEndpointProperties
>
{
private
volatile
ServerWebExchangeMatcher
delegate
;
private
volatile
ServerWebExchangeMatcher
delegate
;
...
@@ -276,9 +284,6 @@ public final class EndpointRequest {
...
@@ -276,9 +284,6 @@ public final class EndpointRequest {
@Override
@Override
protected
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
WebEndpointProperties
>
context
)
{
protected
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
WebEndpointProperties
>
context
)
{
if
(!
EndpointServerWebExchangeMatcher
.
isManagementContext
(
exchange
))
{
return
MatchResult
.
notMatch
();
}
return
this
.
delegate
.
matches
(
exchange
);
return
this
.
delegate
.
matches
(
exchange
);
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java
View file @
ea8f2a72
...
@@ -124,7 +124,7 @@ public final class EndpointRequest {
...
@@ -124,7 +124,7 @@ public final class EndpointRequest {
private
volatile
RequestMatcher
delegate
;
private
volatile
RequestMatcher
delegate
;
private
static
ManagementPortType
managementPortType
;
private
ManagementPortType
managementPortType
;
AbstractRequestMatcher
()
{
AbstractRequestMatcher
()
{
super
(
WebApplicationContext
.
class
);
super
(
WebApplicationContext
.
class
);
...
@@ -132,10 +132,10 @@ public final class EndpointRequest {
...
@@ -132,10 +132,10 @@ public final class EndpointRequest {
@Override
@Override
protected
boolean
ignoreApplicationContext
(
WebApplicationContext
applicationContext
)
{
protected
boolean
ignoreApplicationContext
(
WebApplicationContext
applicationContext
)
{
if
(
managementPortType
==
null
)
{
if
(
this
.
managementPortType
==
null
)
{
managementPortType
=
ManagementPortType
.
get
(
applicationContext
.
getEnvironment
());
this
.
managementPortType
=
ManagementPortType
.
get
(
applicationContext
.
getEnvironment
());
}
}
return
managementPortType
==
ManagementPortType
.
DIFFERENT
return
this
.
managementPortType
==
ManagementPortType
.
DIFFERENT
&&
!
WebServerApplicationContext
.
hasServerNamespace
(
applicationContext
,
"management"
);
&&
!
WebServerApplicationContext
.
hasServerNamespace
(
applicationContext
,
"management"
);
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java
View file @
ea8f2a72
...
@@ -53,6 +53,9 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C> implements S
...
@@ -53,6 +53,9 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C> implements S
@Override
@Override
public
final
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
)
{
public
final
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
)
{
if
(
ignoreApplicationContext
(
exchange
.
getApplicationContext
()))
{
return
MatchResult
.
notMatch
();
}
return
matches
(
exchange
,
getContext
(
exchange
));
return
matches
(
exchange
,
getContext
(
exchange
));
}
}
...
@@ -64,6 +67,18 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C> implements S
...
@@ -64,6 +67,18 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C> implements S
*/
*/
protected
abstract
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
C
>
context
);
protected
abstract
Mono
<
MatchResult
>
matches
(
ServerWebExchange
exchange
,
Supplier
<
C
>
context
);
/**
* Returns if the {@link ApplicationContext} should be ignored and not used for
* matching. If this method returns {@code true} then the context will not be used and
* the {@link #matches(ServerWebExchange) matches} method will return {@code false}.
* @param applicationContext the candidate application context
* @return if the application context should be ignored
* @since 2.2.5
*/
protected
boolean
ignoreApplicationContext
(
ApplicationContext
applicationContext
)
{
return
false
;
}
protected
Supplier
<
C
>
getContext
(
ServerWebExchange
exchange
)
{
protected
Supplier
<
C
>
getContext
(
ServerWebExchange
exchange
)
{
if
(
this
.
context
==
null
)
{
if
(
this
.
context
==
null
)
{
synchronized
(
this
.
contextLock
)
{
synchronized
(
this
.
contextLock
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment