跳到主要内容
版本:7.0.2

响应式

DeepSeek V3 中英对照 Reactive

如果你已经为你的 Reactive 应用程序执行了初始迁移步骤,现在就可以执行特定于 Reactive 应用程序的步骤了。

使用 JwtTypeValidator 验证 typ 标头

如果在执行6.5版本的准备步骤时,您将 validateTypes 设置为 false,现在可以将其移除。您也可以从默认列表中显式移除 JwtTypeValidator

例如,将以下内容:

@Bean
JwtDecoder jwtDecoder() {
NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
.validateTypes(false) 1
// ... your remaining configuration
.build();
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithValidators(
new JwtIssuerValidator(location), JwtTypeValidator.jwt())); 2
return jwtDecoder;
}
  • 关闭 Nimbus 对 typ 的验证

  • 添加默认的 typ 验证器

对此:

@Bean
NimbusReactiveJwtDecoder jwtDecoder() {
NimbusJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
// ... your remaining configuration // <1>
.build();
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(location)); 2
return jwtDecoder;
}
  • validateTypes 现在默认设置为 false

  • 所有 createDefaultXXX 方法都会添加 JwtTypeValidator#jwt