I have an application which is using a custom token based authentication. We are currently migrating the security to Okta Oauth2. In the process of migration, I need to keep both the security for sometime. That is, the clients of my APIs should have the flexibility to use either one of the security for sometime. My WebSecurityConfigurerAdapter is like this now
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/").permitAll().and()
.csrf().disable()
.cors().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterAfter(tokenAuthFilter, X509AuthenticationFilter.class);
}
For the same antMatcher how can I add the okta Oauth2 security also so that either one of it should authenticate my API.
I am able write another WebSecurityConfigurerAdapter with .oauth2ResourceServer().jwt(); dedicatedly for OAuth2, but as the current existing custom token based security is also using the same antmatcher, one of it is only becoming active.