I am dealing with a complex manual security configuration (Spring 3.4, Spring Security 3.2). The filter chains have been configured manually with httpSessionContextIntegrationFilter and other beans configured by us.
<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
<security:filter-chain-map path-type="ant" request-matcher="ant">
<security:filter-chain pattern="/**" filters="httpSessionContextIntegrationFilter, ... beans ...,filterInvocationInterceptor"/>
</security:filter-chain-map>
</bean>
Now, I need to add CSRF protection. I cannot add http and csrf tags, as http is duplicating the manual config. Instead, I tried to configure this in Java, but the Java config does not add CSRF filter.
@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
}
I declared the bean <bean class="package.WebSecurityConfig"/> in application context, yet WebSecurityConfigurerAdapter.configure method is never called on app context creation.
How can I add CSRF protection here? Do I need to insert CSRFFilter manually as well?