リアクティブ
リアクティブアプリケーションの最初の移行手順をすでに実行している場合は、リアクティブアプリケーションに固有の手順を実行する準備ができています。
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
}
| 1 | - Nimbus をオフにして typ を確認します |
| 2 | - デフォルトの 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
}
| 1 | - validateTypes はデフォルトで false になります |
| 2 | - JwtTypeValidator#jwt はすべての createDefaultXXX メソッドで追加されます |