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
e753b530
Commit
e753b530
authored
Jul 27, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EndpointRequest should match links with trailing slash
Fixes gh-13921
parent
f7b90a73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
EndpointRequest.java
...tuate/autoconfigure/security/servlet/EndpointRequest.java
+16
-6
EndpointRequestTests.java
...autoconfigure/security/reactive/EndpointRequestTests.java
+9
-0
EndpointRequestTests.java
.../autoconfigure/security/servlet/EndpointRequestTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java
View file @
e753b530
...
...
@@ -157,6 +157,14 @@ public final class EndpointRequest {
protected
abstract
RequestMatcher
createDelegate
(
WebApplicationContext
context
,
RequestMatcherFactory
requestMatcherFactory
);
protected
List
<
RequestMatcher
>
getLinksMatchers
(
RequestMatcherFactory
requestMatcherFactory
,
String
basePath
)
{
List
<
RequestMatcher
>
linksMatchers
=
new
ArrayList
<>();
linksMatchers
.
add
(
requestMatcherFactory
.
antPath
(
basePath
));
linksMatchers
.
add
(
requestMatcherFactory
.
antPath
(
basePath
,
"/"
));
return
linksMatchers
;
}
}
/**
...
...
@@ -220,10 +228,10 @@ public final class EndpointRequest {
streamPaths
(
this
.
excludes
,
pathMappedEndpoints
).
forEach
(
paths:
:
remove
);
List
<
RequestMatcher
>
delegateMatchers
=
getDelegateMatchers
(
requestMatcherFactory
,
paths
);
if
(
this
.
includeLinks
&&
StringUtils
.
hasText
(
pathMappedEndpoints
.
getBasePath
()
))
{
delegateMatchers
.
add
(
requestMatcherFactory
.
antPath
(
pathMappedEndpoints
.
getBasePath
()
));
String
basePath
=
pathMappedEndpoints
.
getBasePath
();
if
(
this
.
includeLinks
&&
StringUtils
.
hasText
(
basePath
))
{
delegateMatchers
.
addAll
(
getLinksMatchers
(
requestMatcherFactory
,
basePath
));
}
return
new
OrRequestMatcher
(
delegateMatchers
);
}
...
...
@@ -271,8 +279,10 @@ public final class EndpointRequest {
RequestMatcherFactory
requestMatcherFactory
)
{
WebEndpointProperties
properties
=
context
.
getBean
(
WebEndpointProperties
.
class
);
if
(
StringUtils
.
hasText
(
properties
.
getBasePath
()))
{
return
requestMatcherFactory
.
antPath
(
properties
.
getBasePath
());
String
basePath
=
properties
.
getBasePath
();
if
(
StringUtils
.
hasText
(
basePath
))
{
return
new
OrRequestMatcher
(
getLinksMatchers
(
requestMatcherFactory
,
basePath
));
}
return
EMPTY_MATCHER
;
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java
View file @
e753b530
...
...
@@ -59,6 +59,14 @@ public class EndpointRequestTests {
assertMatcher
(
matcher
).
matches
(
"/actuator"
);
}
@Test
public
void
toAnyEndpointShouldMatchEndpointPathWithTrailingSlash
()
{
ServerWebExchangeMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
();
assertMatcher
(
matcher
).
matches
(
"/actuator/foo/"
);
assertMatcher
(
matcher
).
matches
(
"/actuator/bar/"
);
assertMatcher
(
matcher
).
matches
(
"/actuator/"
);
}
@Test
public
void
toAnyEndpointWhenBasePathIsEmptyShouldNotMatchLinks
()
{
ServerWebExchangeMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
();
...
...
@@ -104,6 +112,7 @@ public class EndpointRequestTests {
assertMatcher
(
matcher
).
doesNotMatch
(
"/actuator/foo"
);
assertMatcher
(
matcher
).
doesNotMatch
(
"/actuator/bar"
);
assertMatcher
(
matcher
).
matches
(
"/actuator"
);
assertMatcher
(
matcher
).
matches
(
"/actuator/"
);
}
@Test
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequestTests.java
View file @
e753b530
...
...
@@ -54,10 +54,20 @@ public class EndpointRequestTests {
public
void
toAnyEndpointShouldMatchEndpointPath
()
{
RequestMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
();
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/foo"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/foo/zoo/"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/bar"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/bar/baz"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator"
);
}
@Test
public
void
toAnyEndpointShouldMatchEndpointPathWithTrailingSlash
()
{
RequestMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
();
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/foo/"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/bar/"
);
assertMatcher
(
matcher
,
"/actuator"
,
"/"
).
matches
(
"/actuator/"
);
}
@Test
public
void
toAnyEndpointWhenBasePathIsEmptyShouldNotMatchLinks
()
{
RequestMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
();
...
...
@@ -127,6 +137,7 @@ public class EndpointRequestTests {
assertMatcher
(
matcher
).
doesNotMatch
(
"/actuator/foo"
);
assertMatcher
(
matcher
).
doesNotMatch
(
"/actuator/bar"
);
assertMatcher
(
matcher
).
matches
(
"/actuator"
);
assertMatcher
(
matcher
).
matches
(
"/actuator/"
);
}
@Test
...
...
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