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
e6eca04a
Commit
e6eca04a
authored
Mar 06, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make EndpointRequestMatcher#excluding public
Fixes gh-12354
parent
44c48ec5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
6 deletions
+22
-6
EndpointRequest.java
...uate/autoconfigure/security/reactive/EndpointRequest.java
+2
-2
EndpointRequest.java
...tuate/autoconfigure/security/servlet/EndpointRequest.java
+2
-2
SecurityConfiguration.java
...sample/actuator/customsecurity/SecurityConfiguration.java
+2
-1
SampleActuatorCustomSecurityApplicationTests.java
...ecurity/SampleActuatorCustomSecurityApplicationTests.java
+7
-0
SampleSecureWebFluxCustomSecurityTests.java
...ecure/webflux/SampleSecureWebFluxCustomSecurityTests.java
+9
-1
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java
View file @
e6eca04a
...
...
@@ -125,13 +125,13 @@ public final class EndpointRequest {
this
.
excludes
=
excludes
;
}
EndpointServerWebExchangeMatcher
excluding
(
Class
<?>...
endpoints
)
{
public
EndpointServerWebExchangeMatcher
excluding
(
Class
<?>...
endpoints
)
{
List
<
Object
>
excludes
=
new
ArrayList
<>(
this
.
excludes
);
excludes
.
addAll
(
Arrays
.
asList
((
Object
[])
endpoints
));
return
new
EndpointServerWebExchangeMatcher
(
this
.
includes
,
excludes
);
}
EndpointServerWebExchangeMatcher
excluding
(
String
...
endpoints
)
{
public
EndpointServerWebExchangeMatcher
excluding
(
String
...
endpoints
)
{
List
<
Object
>
excludes
=
new
ArrayList
<>(
this
.
excludes
);
excludes
.
addAll
(
Arrays
.
asList
((
Object
[])
endpoints
));
return
new
EndpointServerWebExchangeMatcher
(
this
.
includes
,
excludes
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java
View file @
e6eca04a
...
...
@@ -120,13 +120,13 @@ public final class EndpointRequest {
this
.
excludes
=
excludes
;
}
EndpointRequestMatcher
excluding
(
Class
<?>...
endpoints
)
{
public
EndpointRequestMatcher
excluding
(
Class
<?>...
endpoints
)
{
List
<
Object
>
excludes
=
new
ArrayList
<>(
this
.
excludes
);
excludes
.
addAll
(
Arrays
.
asList
((
Object
[])
endpoints
));
return
new
EndpointRequestMatcher
(
this
.
includes
,
excludes
);
}
EndpointRequestMatcher
excluding
(
String
...
endpoints
)
{
public
EndpointRequestMatcher
excluding
(
String
...
endpoints
)
{
List
<
Object
>
excludes
=
new
ArrayList
<>(
this
.
excludes
);
excludes
.
addAll
(
Arrays
.
asList
((
Object
[])
endpoints
));
return
new
EndpointRequestMatcher
(
this
.
includes
,
excludes
);
...
...
spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/java/sample/actuator/customsecurity/SecurityConfiguration.java
View file @
e6eca04a
...
...
@@ -17,6 +17,7 @@
package
sample
.
actuator
.
customsecurity
;
import
org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
;
import
org.springframework.boot.actuate.web.mappings.MappingsEndpoint
;
import
org.springframework.boot.autoconfigure.security.servlet.PathRequest
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -43,7 +44,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
// @formatter:off
http
.
authorizeRequests
()
.
requestMatchers
(
EndpointRequest
.
to
(
"health"
,
"info"
)).
permitAll
()
.
requestMatchers
(
EndpointRequest
.
toAnyEndpoint
()).
hasRole
(
"ACTUATOR"
)
.
requestMatchers
(
EndpointRequest
.
toAnyEndpoint
()
.
excluding
(
MappingsEndpoint
.
class
)
).
hasRole
(
"ACTUATOR"
)
.
requestMatchers
(
PathRequest
.
toStaticResources
().
atCommonLocations
()).
permitAll
()
.
antMatchers
(
"/foo"
).
permitAll
()
.
antMatchers
(
"/**"
).
hasRole
(
"USER"
)
...
...
spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java
View file @
e6eca04a
...
...
@@ -125,6 +125,13 @@ public class SampleActuatorCustomSecurityApplicationTests {
assertThat
(
entity
.
getHeaders
().
getFirst
(
"echo"
)).
isEqualTo
(
"test"
);
}
@Test
public
void
actuatorExcludedFromEndpointRequestMatcher
()
{
ResponseEntity
<
Object
>
entity
=
userRestTemplate
().
getForEntity
(
"/actuator/mappings"
,
Object
.
class
);
assertThat
(
entity
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
}
private
TestRestTemplate
restTemplate
()
{
return
configure
(
new
TestRestTemplate
());
}
...
...
spring-boot-samples/spring-boot-sample-secure-webflux/src/test/java/sample/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java
View file @
e6eca04a
...
...
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.autoconfigure.security.reactive.EndpointRequest
;
import
org.springframework.boot.actuate.web.mappings.MappingsEndpoint
;
import
org.springframework.boot.autoconfigure.security.reactive.PathRequest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -78,6 +79,13 @@ public class SampleSecureWebFluxCustomSecurityTests {
.
expectStatus
().
isOk
();
}
@Test
public
void
actuatorExcludedFromEndpointRequestMatcher
()
{
this
.
webClient
.
get
().
uri
(
"/actuator/mappings"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
()
.
expectStatus
().
isOk
();
}
@Test
public
void
staticResourceShouldBeAccessible
()
{
this
.
webClient
.
get
().
uri
(
"/css/bootstrap.min.css"
)
...
...
@@ -100,7 +108,7 @@ public class SampleSecureWebFluxCustomSecurityTests {
@Bean
public
SecurityWebFilterChain
springSecurityFilterChain
(
ServerHttpSecurity
http
)
{
http
.
authorizeExchange
().
matchers
(
EndpointRequest
.
to
(
"health"
,
"info"
))
.
permitAll
().
matchers
(
EndpointRequest
.
toAnyEndpoint
())
.
permitAll
().
matchers
(
EndpointRequest
.
toAnyEndpoint
()
.
excluding
(
MappingsEndpoint
.
class
)
)
.
hasRole
(
"ACTUATOR"
)
.
matchers
(
PathRequest
.
toStaticResources
().
atCommonLocations
())
.
permitAll
().
pathMatchers
(
"/login"
).
permitAll
().
anyExchange
()
...
...
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