简体   繁体   中英

Spring security filter doesn't work. Spring bug?

I added to spring config my own custom filter:

@Override
public void configure(HttpSecurity http) throws Exception {
    http.addFilterBefore(filter, BasicAuthenticationFilter.class);
    http.csrf().disable();
    http.authorizeRequests().antMatchers("/oauth/token").fullyAuthenticated();
}

but doFilter(...) doesn't invoke. I need to proccess request before it will be "eaten" by spring-security-oauth. How to make it work?

According to the documentation, addFilterBefore configuration method "allows adding a filter before one of the known Filter classes. The known Filter instances are either a Filter listed in HttpSecurityBuilder.addFilter(Filter) or a Filter that has already been added using HttpSecurityBuilder.addFilterAfter(Filter, Class) or HttpSecurityBuilder.addFilterBefore(Filter, Class) "

HttpSecurity documentaion

This basically means that your filter will be applied if and only if BasicAuthenticationFilter is already registered to process your requests, which is probably not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM