【发布时间】:2019-02-10 15:37:13
【问题描述】:
我们有一个项目:
+------------------------------------+
| | 1. gets the token
| Authorization Server (Auth) | <------------------+
| - spring-security-oauth2:2.0.14 | |
| | |
+------------------------------------+ +
user
+
+------------------------------------+ |
| | 2. uses the token |
| Resource Server (RS) | to access resourcs|
| - spring-security-oauth2:5.1.0 | <------------------+
| |
+------------------------------------+
我们一直在没有 Webflux 的环境中工作,一切都按预期工作。值得一提的是,这个 JWT 有以下声明:exp、user_name、authorities、jti、client_id、scope。
所有资源都有一个额外的变量:
@GetMapping("/{id}/car")
public SomeDto someResourceMethod(@PathVariable("id") CarId carId, Principal principal)
-
在 “Spring Web” 中(不使用 Reactor):
Principal被实例化为OAuth2Authentication,我们在上面有操作getName。 在 "Spring Webflux" 中(使用 Reactor):
Principal被实例化为JwtAuthenticationToken,我们现在有了getSubject操作,但自声明 @ 以来它为空987654329@ 为空。
您认为我们应该如何处理这个问题?创建一个新的JwtDecoder?我们使用的是 Spring 5.1,解码器是NimbusReactiveJwtDecoder。
【问题讨论】:
标签: spring-boot spring-security project-reactor