I am running Spring-Cloud-Gateway and below is my configuration. The legacy API uses a different JWT token and new API will be using a UAA server. I am trying to skip legacy APIs with Authorization header and a Bearer token. But Still it is continuing to be decoded via JwtReactiveAuthenticationManager.
Can you please help me understand how to instruct Spring security to skip the path even if Auth header is present? Thanks
@EnableWebFluxSecurity
@Slf4j
public class GatewaySecurityConfig
{
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http)
{
http.httpBasic().disable()
.csrf().disable()
.formLogin().disable()
.logout().disable();
http.authorizeExchange().pathMatchers("/legacy/**").permitAll().anyExchange().authenticated()
.and()
.oauth2ResourceServer().jwt().jwtAuthenticationConverter(jwtAuthenticationConverter());
return http.build();
}
}
Samples
$ curl -X POST http://localhost/legacy/v1/orders -H 'authorization: Bearer <old JWT>' --> Fails with 401
$ curl -X POST http://localhost/legacy/v1/orders --> This one gets skipped and works as expected