Polish SecurityContextHolderStrategy XML Configuration for Defaults

Issue gh-11061
This commit is contained in:
Josh Cummings 2022-06-28 11:45:35 -06:00
parent 944f565c16
commit 97cb2a7d91
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
1 changed files with 9 additions and 0 deletions

View File

@ -600,6 +600,7 @@ class HttpConfigurationBuilder {
this.servApiFilter = GrantedAuthorityDefaultsParserUtils.registerWithDefaultRolePrefix(this.pc,
SecurityContextHolderAwareRequestFilterBeanFactory.class);
this.servApiFilter.getPropertyValues().add("authenticationManager", authenticationManager);
this.servApiFilter.getPropertyValues().add("securityContextHolderStrategy", this.holderStrategyRef);
}
}
@ -902,12 +903,20 @@ class HttpConfigurationBuilder {
private SecurityContextHolderAwareRequestFilter filter = new SecurityContextHolderAwareRequestFilter();
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
.getContextHolderStrategy();
@Override
public SecurityContextHolderAwareRequestFilter getBean() {
this.filter.setSecurityContextHolderStrategy(this.securityContextHolderStrategy);
this.filter.setRolePrefix(this.rolePrefix);
return this.filter;
}
void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) {
this.securityContextHolderStrategy = securityContextHolderStrategy;
}
}
static class SecurityContextHolderStrategyFactory implements FactoryBean<SecurityContextHolderStrategy> {