响应式
如果你已经为你的 Reactive 应用程序执行了初始迁移步骤,现在就可以执行特定于 Reactive 应用程序的步骤了。
使用 JwtTypeValidator 验证 typ 标头
如果在执行6.5版本的准备步骤时,您将 validateTypes 设置为 false,现在可以将其移除。您也可以从默认列表中显式移除 JwtTypeValidator。
例如,将以下内容:
- Java
- Kotlin
@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;
}
@Bean
fun jwtDecoder(): JwtDecoder {
val jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
.validateTypes(false) 1
// ... your remaining configuration
.build()
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithValidators(
JwtIssuerValidator(location), JwtTypeValidator.jwt())) 2
return jwtDecoder
}
关闭 Nimbus 对
typ的验证添加默认的
typ验证器
对此:
- Java
- Kotlin
@Bean
NimbusReactiveJwtDecoder jwtDecoder() {
NimbusJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
// ... your remaining configuration // <1>
.build();
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(location)); 2
return jwtDecoder;
}
@Bean
fun jwtDecoder(): NimbusReactiveJwtDecoder {
val jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
// ... your remaining configuration
.build()
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(location)) 2
return jwtDecoder
}
validateTypes现在默认设置为false所有
createDefaultXXX方法都会添加JwtTypeValidator#jwt