Java: add test for qhelp good example

This commit is contained in:
Jami Cogswell
2025-02-23 23:37:05 -05:00
parent 9e51b014d2
commit f65a5b9a66
3 changed files with 15 additions and 0 deletions

View File

@@ -271,4 +271,11 @@ public class SpringBootActuatorsTest {
http.securityMatcher(EndpointRequest.toAnyEndpoint());
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator
}
// QHelp Good example
protected void configureQhelpGood(HttpSecurity http) throws Exception {
// GOOD: only users with ENDPOINT_ADMIN role are allowed to access the actuator endpoints
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests((requests) ->
requests.anyRequest().hasRole("ENDPOINT_ADMIN"));
}
}

View File

@@ -14,5 +14,9 @@ public final class AuthorizeHttpRequestsConfigurer<H extends HttpSecurityBuilder
public AuthorizationManagerRequestMatcherRegistry permitAll() {
return null;
}
public AuthorizationManagerRequestMatcherRegistry hasRole(String role) {
return null;
}
}
}

View File

@@ -12,5 +12,9 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
public ExpressionInterceptUrlRegistry permitAll() {
return null;
}
public ExpressionInterceptUrlRegistry hasRole(String role) {
return null;
}
}
}