Skip to content

Commit

Permalink
Consolidate ExpressionAuthorizationDecision
Browse files Browse the repository at this point in the history
Issue gh-11493
  • Loading branch information
jzheaux committed Jul 13, 2022
1 parent 281814a commit db25a37
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
*
* @author Marcus Da Coregio
* @since 5.6
* @deprecated Use
* {@link org.springframework.security.authorization.ExpressionAuthorizationDecision}
* instead
*/
@Deprecated
public class ExpressionAttributeAuthorizationDecision extends AuthorizationDecision {

private final ExpressionAttribute expressionAttribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.authorization.AuthorizationDecision;
import org.springframework.security.authorization.AuthorizationManager;
import org.springframework.security.authorization.ExpressionAuthorizationDecision;
import org.springframework.security.core.Authentication;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -76,7 +77,7 @@ public AuthorizationDecision check(Supplier<Authentication> authentication, Meth
mi.getMethodInvocation());
this.expressionHandler.setReturnObject(mi.getResult(), ctx);
boolean granted = ExpressionUtils.evaluateAsBoolean(attribute.getExpression(), ctx);
return new ExpressionAttributeAuthorizationDecision(granted, attribute);
return new ExpressionAuthorizationDecision(granted, attribute.getExpression());
}

private final class PostAuthorizeExpressionAttributeRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authorization.AuthorizationDecision;
import org.springframework.security.authorization.AuthorizationManager;
import org.springframework.security.authorization.ExpressionAuthorizationDecision;
import org.springframework.security.core.Authentication;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -74,7 +75,7 @@ public AuthorizationDecision check(Supplier<Authentication> authentication, Meth
}
EvaluationContext ctx = this.expressionHandler.createEvaluationContext(authentication, mi);
boolean granted = ExpressionUtils.evaluateAsBoolean(attribute.getExpression(), ctx);
return new ExpressionAttributeAuthorizationDecision(granted, attribute);
return new ExpressionAuthorizationDecision(granted, attribute.getExpression());
}

private final class PreAuthorizeExpressionAttributeRegistry
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.security.access.expression.SecurityExpressionHandler;
import org.springframework.security.authorization.AuthorizationDecision;
import org.springframework.security.authorization.AuthorizationManager;
import org.springframework.security.authorization.ExpressionAuthorizationDecision;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
import org.springframework.util.Assert;
Expand Down

0 comments on commit db25a37

Please sign in to comment.