使用自定义 JwtAuthenticationConverter 更新已弃用的 jwt-function

Flo*_*cke 2 java spring spring-security

我有这行代码:

http.oauth2ResourceServer(server -> server.jwt().jwtAuthenticationConverter(jwtAuthenticationConverter()));
Run Code Online (Sandbox Code Playgroud)

@Bean
public JwtAuthenticationConverter jwtAuthenticationConverter() {
...
}
Run Code Online (Sandbox Code Playgroud)

jwt() 已弃用,我尝试使用jwt(JwtConfigurer). 这是如何运作的?如何使用该函数注册我的 AuthenticationConverter?

谢谢!

Ber*_*glu 7

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())
            )
     )
Run Code Online (Sandbox Code Playgroud)