How to disable authorization for a request having particular headers in spring boot security?

Viewed 65

Currently I have a spring boot app that uses oauth2 authorization and validates a request with token against the jwt resource server.

@Configuration
public class CustomSecurityConfiguration extends WebSecurityConfigurerAdapter {

 @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests(authz -> authz
                .anyRequest().authenticated())
            .oauth2ResourceServer(oauth2 -> oauth2.jwt());
    }
}

How can i disable this authorization for a request having particular headers? For example if a request comes with a header as "internal-key", I want to disable jwt authorization for such requests and allow that request.

0 Answers
Related