|
2 | 2 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
3 | 3 |
|
4 | 4 | public class SpringBootActuatorsTest {
|
| 5 | + // Spring security version 5.2.3 used `authorizeRequests` and `requestMatcher(s)` |
5 | 6 | protected void configure(HttpSecurity http) throws Exception {
|
6 | 7 | http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests(requests -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator
|
7 | 8 | }
|
@@ -101,4 +102,166 @@ protected void configureOkNoPermitAll6(HttpSecurity http) throws Exception {
|
101 | 102 | protected void configureOkNoPermitAll7(HttpSecurity http) throws Exception {
|
102 | 103 | http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeRequests().anyRequest();
|
103 | 104 | }
|
| 105 | + |
| 106 | + // Spring security version 5.5.0 introduced `authorizeHttpRequests` |
| 107 | + protected void configure_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 108 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests(requests -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator |
| 109 | + } |
| 110 | + |
| 111 | + protected void configure2_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 112 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); // $ hasExposedSpringBootActuator |
| 113 | + } |
| 114 | + |
| 115 | + protected void configure3_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 116 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); // $ hasExposedSpringBootActuator |
| 117 | + } |
| 118 | + |
| 119 | + protected void configure4_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 120 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest().permitAll(); // $ hasExposedSpringBootActuator |
| 121 | + } |
| 122 | + |
| 123 | + protected void configure5_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 124 | + http.authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); // $ hasExposedSpringBootActuator |
| 125 | + } |
| 126 | + |
| 127 | + protected void configure6_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 128 | + http.authorizeHttpRequests(requests -> requests.requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()); // $ hasExposedSpringBootActuator |
| 129 | + } |
| 130 | + |
| 131 | + protected void configure7_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 132 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest().permitAll(); // $ hasExposedSpringBootActuator |
| 133 | + } |
| 134 | + |
| 135 | + protected void configureOk3_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 136 | + http.authorizeHttpRequests().anyRequest().permitAll(); |
| 137 | + } |
| 138 | + |
| 139 | + protected void configureOk4_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 140 | + http.authorizeHttpRequests(authz -> authz.anyRequest().permitAll()); |
| 141 | + } |
| 142 | + |
| 143 | + protected void configureOkSafeEndpoints1_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 144 | + http.requestMatcher(EndpointRequest.to("health", "info")).authorizeHttpRequests(requests -> requests.anyRequest().permitAll()); |
| 145 | + } |
| 146 | + |
| 147 | + protected void configureOkSafeEndpoints2_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 148 | + http.requestMatcher(EndpointRequest.to("health")).authorizeHttpRequests().requestMatchers(EndpointRequest.to("health")).permitAll(); |
| 149 | + } |
| 150 | + |
| 151 | + protected void configureOkSafeEndpoints3_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 152 | + http.requestMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeHttpRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll(); |
| 153 | + } |
| 154 | + |
| 155 | + protected void configureOkSafeEndpoints4_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 156 | + http.requestMatcher(EndpointRequest.to("health", "info")).authorizeHttpRequests().anyRequest().permitAll(); |
| 157 | + } |
| 158 | + |
| 159 | + protected void configureOkSafeEndpoints5_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 160 | + http.authorizeHttpRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll(); |
| 161 | + } |
| 162 | + |
| 163 | + protected void configureOkSafeEndpoints6_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 164 | + http.authorizeHttpRequests(requests -> requests.requestMatchers(EndpointRequest.to("health", "info")).permitAll()); |
| 165 | + } |
| 166 | + |
| 167 | + protected void configureOkSafeEndpoints7_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 168 | + http.requestMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeHttpRequests().anyRequest().permitAll(); |
| 169 | + } |
| 170 | + |
| 171 | + protected void configureOkNoPermitAll1_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 172 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests(requests -> requests.anyRequest()); |
| 173 | + } |
| 174 | + |
| 175 | + protected void configureOkNoPermitAll2_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 176 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 177 | + } |
| 178 | + |
| 179 | + protected void configureOkNoPermitAll3_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 180 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 181 | + } |
| 182 | + |
| 183 | + protected void configureOkNoPermitAll4_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 184 | + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest(); |
| 185 | + } |
| 186 | + |
| 187 | + protected void configureOkNoPermitAll5_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 188 | + http.authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 189 | + } |
| 190 | + |
| 191 | + protected void configureOkNoPermitAll6_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 192 | + http.authorizeHttpRequests(requests -> requests.requestMatchers(EndpointRequest.toAnyEndpoint())); |
| 193 | + } |
| 194 | + |
| 195 | + protected void configureOkNoPermitAll7_authorizeHttpRequests(HttpSecurity http) throws Exception { |
| 196 | + http.requestMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest(); |
| 197 | + } |
| 198 | + |
| 199 | + // Spring security version 5.8.0 introduced `securityMatcher(s)` |
| 200 | + protected void configure_securityMatchers(HttpSecurity http) throws Exception { |
| 201 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests(requests -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator |
| 202 | + } |
| 203 | + |
| 204 | + protected void configure2_securityMatchers(HttpSecurity http) throws Exception { |
| 205 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); // $ hasExposedSpringBootActuator |
| 206 | + } |
| 207 | + |
| 208 | + protected void configure3_securityMatchers(HttpSecurity http) throws Exception { |
| 209 | + http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll(); // $ hasExposedSpringBootActuator |
| 210 | + } |
| 211 | + |
| 212 | + protected void configure4_securityMatchers(HttpSecurity http) throws Exception { |
| 213 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest().permitAll(); // $ hasExposedSpringBootActuator |
| 214 | + } |
| 215 | + |
| 216 | + protected void configure7_securityMatchers(HttpSecurity http) throws Exception { |
| 217 | + http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest().permitAll(); // $ hasExposedSpringBootActuator |
| 218 | + } |
| 219 | + |
| 220 | + protected void configureOk1_securityMatchers(HttpSecurity http) throws Exception { |
| 221 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()); |
| 222 | + } |
| 223 | + |
| 224 | + protected void configureOk2_securityMatchers(HttpSecurity http) throws Exception { |
| 225 | + http.securityMatchers().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 226 | + } |
| 227 | + |
| 228 | + protected void configureOkSafeEndpoints1_securityMatchers(HttpSecurity http) throws Exception { |
| 229 | + http.securityMatcher(EndpointRequest.to("health", "info")).authorizeHttpRequests(requests -> requests.anyRequest().permitAll()); |
| 230 | + } |
| 231 | + |
| 232 | + protected void configureOkSafeEndpoints2_securityMatchers(HttpSecurity http) throws Exception { |
| 233 | + http.securityMatcher(EndpointRequest.to("health")).authorizeHttpRequests().requestMatchers(EndpointRequest.to("health")).permitAll(); |
| 234 | + } |
| 235 | + |
| 236 | + protected void configureOkSafeEndpoints3_securityMatchers(HttpSecurity http) throws Exception { |
| 237 | + http.securityMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeHttpRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll(); |
| 238 | + } |
| 239 | + |
| 240 | + protected void configureOkSafeEndpoints4_securityMatchers(HttpSecurity http) throws Exception { |
| 241 | + http.securityMatcher(EndpointRequest.to("health", "info")).authorizeHttpRequests().anyRequest().permitAll(); |
| 242 | + } |
| 243 | + |
| 244 | + protected void configureOkSafeEndpoints7_securityMatchers(HttpSecurity http) throws Exception { |
| 245 | + http.securityMatchers(matcher -> EndpointRequest.to("health", "info")).authorizeHttpRequests().anyRequest().permitAll(); |
| 246 | + } |
| 247 | + |
| 248 | + protected void configureOkNoPermitAll1_securityMatchers(HttpSecurity http) throws Exception { |
| 249 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests(requests -> requests.anyRequest()); |
| 250 | + } |
| 251 | + |
| 252 | + protected void configureOkNoPermitAll2_securityMatchers(HttpSecurity http) throws Exception { |
| 253 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 254 | + } |
| 255 | + |
| 256 | + protected void configureOkNoPermitAll3_securityMatchers(HttpSecurity http) throws Exception { |
| 257 | + http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().requestMatchers(EndpointRequest.toAnyEndpoint()); |
| 258 | + } |
| 259 | + |
| 260 | + protected void configureOkNoPermitAll4_securityMatchers(HttpSecurity http) throws Exception { |
| 261 | + http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest(); |
| 262 | + } |
| 263 | + |
| 264 | + protected void configureOkNoPermitAll7_securityMatchers(HttpSecurity http) throws Exception { |
| 265 | + http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest(); |
| 266 | + } |
104 | 267 | }
|
0 commit comments