Reputation: 4011
I have a problem with my filter. I have it defined this way:
@WebFilter("springSecurityFilterChain")
public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFilter {...}
And in my web-fragment.xml I have:
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The pattern should be valid but I keep getting this exception:
java.lang.IllegalArgumentException: Invalid <url-pattern> springSecurityFilterChain in filter mapping
I've also tried to changing the pattern with "/", "/security/*", "" both in the XML and in @WebFilter annotation but I keep getting this exception. Can someone explain me what I'm doing wrong?
Thank you.
EDIT
This is the Spring Security config:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.exceptionHandling()
.authenticationEntryPoint(restAuthenticationEntryPoint)
.and().authorizeRequests().
anyRequest().authenticated().and()
.addFilterBefore(jwtAuthenticationFilter, BasicAuthenticationFilter.class);
http.antMatcher("/rest/login").securityContext().disable();
}
Upvotes: 0
Views: 238
Reputation: 10497
You have a problem with your @WebFilter
annotation. If you don't specify anything in @WebFilter
annotation, then by default it takes param as URL pattern, which is springSecurityFilterChain
in your case.
So for your case, you can use either
@WebFilter("/*")
public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFilter {...}
without specifying anything in your xml file, or below:
@WebFilter(filterName = "abc")
public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFilter {...}
and in your xml file, you can specify the URL pattern as follow:
<filter-mapping>
<filter-name>abc</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Upvotes: 1