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

huangapple go评论137阅读模式
英文:

Updating depreacted jwt-function with custom JwtAuthenticationConverter

问题

我有这行代码:

    http.oauth2ResourceServer(server -> server.jwt().jwtAuthenticationConverter(jwtAuthenticationConverter()));
    
用以下代码替代:

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

jwt()已被弃用,我尝试使用<code>jwt(JwtConfigurer)</code>。 这个怎么用?如何将我的AuthenticationConverter注册到该函数中?

谢谢!
英文:

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 <code>jwt(JwtConfigurer)</code>. How does that work? How to register my AuthenticationConverter with that function?

Thanks!

答案1

得分: 4

Sure, here's the translated code snippet:

http
    .oauth2ResourceServer(configurer ->
        configurer.jwt(
            jwtConfigurer -> jwtConfigurer.jwtAuthenticationConverter(jwtAuthenticationConverter())
        )
    )
英文:

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

 http
     .oauth2ResourceServer(configurer -&gt;
            configurer.jwt(
                jwtConfigurer -&gt; jwtConfigurer.jwtAuthenticationConverter(jwtAuthenticationConverter())
            )
     )

huangapple
  • 本文由 发表于 2023年6月30日 00:06:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76582802.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定