根据Spring Security的此文档,我添加了一个自定义AuthorizationManager<MethodInvocation>
当魔豆被触发时
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public Advisor customAuthorize() {
JdkRegexpMethodPointcut pattern = new JdkRegexpMethodPointcut();
pattern.setPattern("xxx.*");
AuthorizationManager<MethodInvocation> rule = new CustomAuthorizationManager();
AuthorizationManagerBeforeMethodInterceptor interceptor = new AuthorizationManagerBeforeMethodInterceptor(pattern, rule);
interceptor.setOrder(AuthorizationInterceptorsOrder.PRE_AUTHORIZE.getOrder() - 1);
return interceptor;
}
低于check
的方法根本不会触发UnsupportedOperationException
。
public class CustomAuthorizationManager implements AuthorizationManager<MethodInvocation> {
@Override
public AuthorizationDecision check(Supplier<Authentication> authentication, MethodInvocation object) {
throw new UnsupportedOperationException("Unimplemented method 'check'");
}
}
有什么建议我错过了什么吗?
1条答案
按热度按时间8aqjt8rx1#
这是因为
JdkRegexpMethodPointcut
表达式。这与控制器名称空间不匹配。在我的情况下,我必须将其设置为