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
}
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 方法新增
© . This site is unofficial and not affiliated with VMware.