Polish AuthorizationManager#authorize
Issue gh-14843
This commit is contained in:
+2
-2
@@ -57,8 +57,8 @@ public final class AuthorizationManagerWebInvocationPrivilegeEvaluator
|
||||
public boolean isAllowed(String contextPath, String uri, String method, Authentication authentication) {
|
||||
FilterInvocation filterInvocation = new FilterInvocation(contextPath, uri, method, this.servletContext);
|
||||
HttpServletRequest httpRequest = this.requestTransformer.transform(filterInvocation.getHttpRequest());
|
||||
AuthorizationResult decision = this.authorizationManager.authorize(() -> authentication, httpRequest);
|
||||
return decision == null || decision.isGranted();
|
||||
AuthorizationResult result = this.authorizationManager.authorize(() -> authentication, httpRequest);
|
||||
return result == null || result.isGranted();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -93,10 +93,10 @@ public class AuthorizationFilter extends GenericFilterBean {
|
||||
String alreadyFilteredAttributeName = getAlreadyFilteredAttributeName();
|
||||
request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE);
|
||||
try {
|
||||
AuthorizationResult decision = this.authorizationManager.authorize(this::getAuthentication, request);
|
||||
this.eventPublisher.publishAuthorizationEvent(this::getAuthentication, request, decision);
|
||||
if (decision != null && !decision.isGranted()) {
|
||||
throw new AuthorizationDeniedException("Access Denied", decision);
|
||||
AuthorizationResult result = this.authorizationManager.authorize(this::getAuthentication, request);
|
||||
this.eventPublisher.publishAuthorizationEvent(this::getAuthentication, request, result);
|
||||
if (result != null && !result.isGranted()) {
|
||||
throw new AuthorizationDeniedException("Access Denied", result);
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
+2
@@ -68,7 +68,9 @@ public final class RequestMatcherDelegatingAuthorizationManager implements Autho
|
||||
* @return an {@link AuthorizationDecision}. If there is no {@link RequestMatcher}
|
||||
* matching the request, or the {@link AuthorizationManager} could not decide, then
|
||||
* null is returned
|
||||
* @deprecated please use {@link #authorize(Supplier, Object)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public AuthorizationDecision check(Supplier<Authentication> authentication, HttpServletRequest request) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
|
||||
+4
@@ -48,6 +48,10 @@ public final class DelegatingReactiveAuthorizationManager implements ReactiveAut
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link #authorize(Mono, Object)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, ServerWebExchange exchange) {
|
||||
return Flux.fromIterable(this.mappings)
|
||||
|
||||
Reference in New Issue
Block a user