Open
Description
We should consider supporting expressions in method authorization handlers for simple setups. Currently, if you want to handle authorization denied and map the return value to null
, you must create a MethodAuthorizationDeniedHandler/PostProcessor
class and expose it as a bean:
@HandleAuthorizationDenied(handlerClass = Null.class)
public String getUserEmail() {
// ...
}
@Component
public class Null implements MethodAuthorizationDeniedHandler {
@Override
public Object handle(MethodInvocation methodInvocation, AuthorizationResult result) {
return null;
}
}
That is a little bit too complicated to just return null. A simpler setup could be:
@HandleAuthorizationDenied(handlerExpression = "null")
public String getUserEmail() {
// ...
}
@HandleAuthorizationDenied(handlerExpression = "***")
public String getUserEmail() {
// ...
}
Related: