I created a resource server with the new Spring Resource Server.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
And I'll have two different providers, so I created a JwtIssuerAuthenticationManagerResolver.
JwtIssuerAuthenticationManagerResolver resolver =
new JwtIssuerAuthenticationManagerResolver(
"http://localhost:8180/auth/realms/externalauth",
"http://localhost:8080/auth/realms/myauth");
...
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2ResourceServer(oauth2 ->
oauth2.authenticationManagerResolver(resolver));
}
And I want to after token is considered a valid token, get it and extract and set SecurityContext.
I tried with BearerTokenResolver but didn't work, also I tried with implements Converter<Jwt, AbstractAuthenticationToken>.
But I'm getting this error:
If an authenticationManagerResolver() is configured, then it takes precedence over any jwt() or opaqueToken() configuration.
Thanks in advance