I have custom authentication filter which creates PreAuthenticatedAuthenticationToken
and stores it in security context. This all works fine. Here is the config:
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SsoAuthenticationProvider authenticationProvider;
@Autowired
private SsoAuthenticationFilter ssoAuthenticationFilter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(ssoAuthenticationFilter, SecurityContextPersistenceFilter.class);
}
}
Now my ssoAuthenticationFilter
is part of the FilterChainProxy
, on the right position. Smooth.
But as the ssoAuthenticationFilter
is Filter
it gets picked up by Boot and included as a filter. So my filter chain really looks like:
Filter
)http.addFilterAfter(...)
)Obviously I would like to get rid of the autoregistration of the ssoAuthenticationFilter
here (the first one listed).
Any tips much appreciated.
2 choices:
Add a FilterRegistrationBean
@Bean
with your filter bean as its target filter and mark it as enabled=false
Don't create a @Bean
definition for your filter (normally that's what I do, but YMMV since you might depend on autowiring or something to get it working)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With