【发布时间】:2023-02-01 05:53:20
【问题描述】:
我有一个公开一些 webflux 端点的 spring 应用程序,我使用 jwt 令牌来授权 post 调用,但我们还需要 userinfo 端点提供的信息。 我现在有一个 SecurityWebFilterChain bean,我们正在使用 oauth2ResourceServer 配置,然后调用 userinfoendpoint 进行进一步检查。 验证 jwt 令牌然后获取 userinfo enpoint 信息以进行进一步验证的最佳方法是什么?
ps:授权服务器是第三方的。
无需外部调用用户信息的安全配置
@Bean
public SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
http
.cors()
.and()
.httpBasic().disable()
.formLogin().disable()
.csrf().disable()
.logout().disable()
.oauth2Client()
.and()
.authorizeExchange()
.pathMatchers(HttpMethod.POST).authenticated()
.anyExchange().permitAll()
.and().oauth2ResourceServer().jwt()
;
return http.build();
}
【问题讨论】:
-
当你说“进一步验证”时,你能举个例子吗?
-
通过不使用 JWT 而是使用不透明的令牌而不是构建一些奇怪的自定义流程。
-
@SteveRiesenberg 我们需要从用户信息端点响应中获取一个字段,将其映射并将其添加到权限
标签: java spring spring-boot spring-security spring-webflux