Search code examples
javaspringspring-security

Updating depreacted jwt-function with custom JwtAuthenticationConverter


I have this line of code:

http.oauth2ResourceServer(server -> server.jwt().jwtAuthenticationConverter(jwtAuthenticationConverter()));

with

@Bean
public JwtAuthenticationConverter jwtAuthenticationConverter() {
...
}

jwt() is deprecated and I'm tried to use jwt(JwtConfigurer). How does that work? How to register my AuthenticationConverter with that function?

Thanks!


Solution

  • https://docs.spring.io/spring-security/reference/reactive/oauth2/resource-server/jwt.html#webflux-oauth2resourceserver-jwt-authorization-extraction

     http
         .oauth2ResourceServer(configurer ->
                configurer.jwt(
                    jwtConfigurer -> jwtConfigurer.jwtAuthenticationConverter(jwtAuthenticationConverter())
                )
         )