mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-04 09:42:29 +00:00
Simplify PrePostMethodSecurityConfiguration
Issue gh-9288
This commit is contained in:
parent
c73bd4756d
commit
a43677d36a
@ -49,55 +49,55 @@ final class PrePostMethodSecurityConfiguration implements ApplicationContextAwar
|
|||||||
|
|
||||||
private final PreFilterAuthorizationMethodInterceptor preFilterAuthorizationMethodInterceptor = new PreFilterAuthorizationMethodInterceptor();
|
private final PreFilterAuthorizationMethodInterceptor preFilterAuthorizationMethodInterceptor = new PreFilterAuthorizationMethodInterceptor();
|
||||||
|
|
||||||
|
private final AuthorizationManagerBeforeMethodInterceptor preAuthorizeAuthorizationMethodInterceptor;
|
||||||
|
|
||||||
private final PreAuthorizeAuthorizationManager preAuthorizeAuthorizationManager = new PreAuthorizeAuthorizationManager();
|
private final PreAuthorizeAuthorizationManager preAuthorizeAuthorizationManager = new PreAuthorizeAuthorizationManager();
|
||||||
|
|
||||||
|
private final AuthorizationManagerAfterMethodInterceptor postAuthorizeAuthorizaitonMethodInterceptor;
|
||||||
|
|
||||||
private final PostAuthorizeAuthorizationManager postAuthorizeAuthorizationManager = new PostAuthorizeAuthorizationManager();
|
private final PostAuthorizeAuthorizationManager postAuthorizeAuthorizationManager = new PostAuthorizeAuthorizationManager();
|
||||||
|
|
||||||
private final PostFilterAuthorizationMethodInterceptor postFilterAuthorizationMethodInterceptor = new PostFilterAuthorizationMethodInterceptor();
|
private final PostFilterAuthorizationMethodInterceptor postFilterAuthorizationMethodInterceptor = new PostFilterAuthorizationMethodInterceptor();
|
||||||
|
|
||||||
private final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
|
private final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
|
||||||
|
|
||||||
private boolean customMethodSecurityExpressionHandler = false;
|
PrePostMethodSecurityConfiguration() {
|
||||||
|
this.preAuthorizeAuthorizationManager.setExpressionHandler(this.expressionHandler);
|
||||||
|
this.preAuthorizeAuthorizationMethodInterceptor = AuthorizationManagerBeforeMethodInterceptor
|
||||||
|
.preAuthorize(this.preAuthorizeAuthorizationManager);
|
||||||
|
this.postAuthorizeAuthorizationManager.setExpressionHandler(this.expressionHandler);
|
||||||
|
this.postAuthorizeAuthorizaitonMethodInterceptor = AuthorizationManagerAfterMethodInterceptor
|
||||||
|
.postAuthorize(this.postAuthorizeAuthorizationManager);
|
||||||
|
this.preFilterAuthorizationMethodInterceptor.setExpressionHandler(this.expressionHandler);
|
||||||
|
this.postFilterAuthorizationMethodInterceptor.setExpressionHandler(this.expressionHandler);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||||
Advisor preFilterAuthorizationMethodInterceptor() {
|
Advisor preFilterAuthorizationMethodInterceptor() {
|
||||||
if (!this.customMethodSecurityExpressionHandler) {
|
|
||||||
this.preAuthorizeAuthorizationManager.setExpressionHandler(this.expressionHandler);
|
|
||||||
}
|
|
||||||
return this.preFilterAuthorizationMethodInterceptor;
|
return this.preFilterAuthorizationMethodInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||||
Advisor preAuthorizeAuthorizationMethodInterceptor() {
|
Advisor preAuthorizeAuthorizationMethodInterceptor() {
|
||||||
if (!this.customMethodSecurityExpressionHandler) {
|
return this.preAuthorizeAuthorizationMethodInterceptor;
|
||||||
this.preAuthorizeAuthorizationManager.setExpressionHandler(this.expressionHandler);
|
|
||||||
}
|
|
||||||
return AuthorizationManagerBeforeMethodInterceptor.preAuthorize(this.preAuthorizeAuthorizationManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||||
Advisor postAuthorizeAuthorizationMethodInterceptor() {
|
Advisor postAuthorizeAuthorizationMethodInterceptor() {
|
||||||
if (!this.customMethodSecurityExpressionHandler) {
|
return this.postAuthorizeAuthorizaitonMethodInterceptor;
|
||||||
this.postAuthorizeAuthorizationManager.setExpressionHandler(this.expressionHandler);
|
|
||||||
}
|
|
||||||
return AuthorizationManagerAfterMethodInterceptor.postAuthorize(this.postAuthorizeAuthorizationManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||||
Advisor postFilterAuthorizationMethodInterceptor() {
|
Advisor postFilterAuthorizationMethodInterceptor() {
|
||||||
if (!this.customMethodSecurityExpressionHandler) {
|
|
||||||
this.postFilterAuthorizationMethodInterceptor.setExpressionHandler(this.expressionHandler);
|
|
||||||
}
|
|
||||||
return this.postFilterAuthorizationMethodInterceptor;
|
return this.postFilterAuthorizationMethodInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
void setMethodSecurityExpressionHandler(MethodSecurityExpressionHandler methodSecurityExpressionHandler) {
|
void setMethodSecurityExpressionHandler(MethodSecurityExpressionHandler methodSecurityExpressionHandler) {
|
||||||
this.customMethodSecurityExpressionHandler = true;
|
|
||||||
this.preFilterAuthorizationMethodInterceptor.setExpressionHandler(methodSecurityExpressionHandler);
|
this.preFilterAuthorizationMethodInterceptor.setExpressionHandler(methodSecurityExpressionHandler);
|
||||||
this.preAuthorizeAuthorizationManager.setExpressionHandler(methodSecurityExpressionHandler);
|
this.preAuthorizeAuthorizationManager.setExpressionHandler(methodSecurityExpressionHandler);
|
||||||
this.postAuthorizeAuthorizationManager.setExpressionHandler(methodSecurityExpressionHandler);
|
this.postAuthorizeAuthorizationManager.setExpressionHandler(methodSecurityExpressionHandler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user