I'm trying to implement JWT. I have two endpoints: /api/auth/signin for authentication that returns generated JWT token and /api/auth/me that should return user based on JWT token in the header. I'm trying to configure Spring Security to have access to /api** for only authorized users and I need to exclude /api/auth/signin
Here is a configure() method from class that extends WebSecurityConfigurerAdapter:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/api**")
.httpBasic().disable()
.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers(HttpMethod.POST, "/api/auth/signin").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(jwtAuthorizationFilter(), UsernamePasswordAuthenticationFilter.class);
}
But it still invokes JwtAuthorizationFilter for /api/auth/signin. I also tried to ignore this endpoint with:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.POST,"/api/auth/signin");
}
Is there any other way to ignore it or maybe permitAll() and ignoring() should be used differently?