Как это было решено в Spring Boot 2:
(API доступа ожидает строковый аргумент)
Код: Выделить всё
private ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry mvcMatchers(
ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) {
final List securedUrls = securityProperties.getSecured();
securedUrls.forEach(entry -> {
if (entry.getMethods() != null && !entry.getMethods().isEmpty()) {
entry.getMethods().stream().forEach(httpMethod -> {
ExpressionUrlAuthorizationConfigurer.AuthorizedUrl authorizedUrl = registry
.mvcMatchers(httpMethod, entry.getPatterns().toArray(new String[]{}));
authorizedUrl.fullyAuthenticated();
Optional.ofNullable(entry.getAccess()).ifPresent(spEL -> authorizedUrl.access(spEL));
});
}
});
return registry;
}
Моя Spring Boot 3 пытается обработать выражения SpEL:
Код: Выделить всё
private void configureRequests(AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry requests) {
final List securedUrls = securityProperties.getSecured();
if (securedUrls != null) {
securedUrls.forEach(entry -> {
if (entry.getMethods() != null && !entry.getMethods().isEmpty()) {
entry.getMethods().forEach(httpMethod -> {
var authorizedUrl = requests.requestMatchers(httpMethod, entry.getPatterns().toArray(new String[]{}));
authorizedUrl.fullyAuthenticated();
Optional.ofNullable(entry.getAccess()).ifPresent(spEL -> {
var manager = new WebExpressionAuthorizationManager(spEL);
authorizedUrl.access(manager);
});
});
}
});
}
requests.anyRequest().permitAll();
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... -spring-bo