|
| 1 | +import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; |
| 2 | +import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| 3 | + |
| 4 | +public class SpringBootActuators { |
| 5 | + protected void configure(HttpSecurity http) throws Exception { |
| 6 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests(requests -> requests.anyRequest().permitAll()); |
| 7 | + } |
| 8 | + |
| 9 | + protected void configure2(HttpSecurity http) throws Exception { |
| 10 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); |
| 11 | + } |
| 12 | + |
| 13 | + protected void configure3(HttpSecurity http) throws Exception { |
| 14 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); |
| 15 | + } |
| 16 | + |
| 17 | + protected void configure4(HttpSecurity http) throws Exception { |
| 18 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests().anyRequest().permitAll(); |
| 19 | + } |
| 20 | + |
| 21 | + protected void configure5(HttpSecurity http) throws Exception { |
| 22 | + http.authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); |
| 23 | + } |
| 24 | + |
| 25 | + protected void configure6(HttpSecurity http) throws Exception { |
| 26 | + http.authorizeRequests(requests -> requests.requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()); |
| 27 | + } |
| 28 | + |
| 29 | + protected void configure7(HttpSecurity http) throws Exception { |
| 30 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeRequests().anyRequest().permitAll(); |
| 31 | + } |
| 32 | + |
| 33 | + protected void configureOk1(HttpSecurity http) throws Exception { |
| 34 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()); |
| 35 | + } |
| 36 | + |
| 37 | + protected void configureOk2(HttpSecurity http) throws Exception { |
| 38 | + http.requestMatchers().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 39 | + } |
| 40 | + |
| 41 | + protected void configureOk3(HttpSecurity http) throws Exception { |
| 42 | + http.authorizeRequests().anyRequest().permitAll(); |
| 43 | + } |
| 44 | + |
| 45 | + protected void configureOk4(HttpSecurity http) throws Exception { |
| 46 | + http.authorizeRequests(authz -> authz.anyRequest().permitAll()); |
| 47 | + } |
| 48 | + |
| 49 | + protected void configureOkSafeEndpoints1(HttpSecurity http) throws Exception { |
| 50 | + http.requestMatcher(EndpointRequest.to("health", "info")).authorizeRequests(requests -> requests.anyRequest().permitAll()); |
| 51 | + } |
| 52 | + |
| 53 | + protected void configureOkSafeEndpoints2(HttpSecurity http) throws Exception { |
| 54 | + http.requestMatcher(EndpointRequest.to("health")).authorizeRequests().requestMatchers(EndpointRequest.to("health")).permitAll(); |
| 55 | + } |
| 56 | + |
| 57 | + protected void configureOkSafeEndpoints3(HttpSecurity http) throws Exception { |
| 58 | + http.requestMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll(); |
| 59 | + } |
| 60 | + |
| 61 | + protected void configureOkSafeEndpoints4(HttpSecurity http) throws Exception { |
| 62 | + http.requestMatcher(EndpointRequest.to("health", "info")).authorizeRequests().anyRequest().permitAll(); |
| 63 | + } |
| 64 | + |
| 65 | + protected void configureOkSafeEndpoints5(HttpSecurity http) throws Exception { |
| 66 | + http.authorizeRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll(); |
| 67 | + } |
| 68 | + |
| 69 | + protected void configureOkSafeEndpoints6(HttpSecurity http) throws Exception { |
| 70 | + http.authorizeRequests(requests -> requests.requestMatchers(EndpointRequest.to("health", "info")).permitAll()); |
| 71 | + } |
| 72 | + |
| 73 | + protected void configureOkSafeEndpoints7(HttpSecurity http) throws Exception { |
| 74 | + http.requestMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeRequests().anyRequest().permitAll(); |
| 75 | + } |
| 76 | + |
| 77 | + protected void configureOkNoPermitAll1(HttpSecurity http) throws Exception { |
| 78 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests(requests -> requests.anyRequest()); |
| 79 | + } |
| 80 | + |
| 81 | + protected void configureOkNoPermitAll2(HttpSecurity http) throws Exception { |
| 82 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 83 | + } |
| 84 | + |
| 85 | + protected void configureOkNoPermitAll3(HttpSecurity http) throws Exception { |
| 86 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 87 | + } |
| 88 | + |
| 89 | + protected void configureOkNoPermitAll4(HttpSecurity http) throws Exception { |
| 90 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests().anyRequest(); |
| 91 | + } |
| 92 | + |
| 93 | + protected void configureOkNoPermitAll5(HttpSecurity http) throws Exception { |
| 94 | + http.authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 95 | + } |
| 96 | + |
| 97 | + protected void configureOkNoPermitAll6(HttpSecurity http) throws Exception { |
| 98 | + http.authorizeRequests(requests -> requests.requestMatchers(EndpointRequest.toAnyEndpoint())); |
| 99 | + } |
| 100 | + |
| 101 | + protected void configureOkNoPermitAll7(HttpSecurity http) throws Exception { |
| 102 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeRequests().anyRequest(); |
| 103 | + } |
| 104 | +} |
0 commit comments