pra*_*opa 3 spring-security oauth-2.0 spring-security-oauth2 spring-oauth2 nimbus-jose-jwt
我有一个openam本地运行的 OpenID 提供程序 ( )。我使用的是自签名证书,jwks URL 是 @ https://localhost:8443/openam/oauth2/connect/
由于 SSL 证书是自签名的,因此在解码 OIDC 令牌时出现 SSLHandshake 异常。我尝试使用自定义休息模板,通过创建自定义JwtDecoder(如https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2resourceserver-jwt-decoder-dsl中的建议)
@Bean
public JwtDecoder jwtDecoder() {
NimbusJwtDecoder.withJwkSetUri("https://localhost:8443/openam/oauth2/connect").restOperations(myCustomRestTemplateThatAllowsSelfSignedCerts()).build();
}
Run Code Online (Sandbox Code Playgroud)
不过这个解码器好像没有用过。用于OidcIdTokenDecoderFactory创建解码器。这个类似乎不允许我们传入自定义的jwtDecoder。
为什么不起作用oauthResourceServer().jwt().decoder(customDecoder())?如何让解码器与具有自签名证书的网站 jwks URI 一起使用?
我正在考虑的一种选择是将自签名证书添加到我的 jdk 的 cacerts 文件夹中。
OAuth2LoginAuthenticationFilter正在调用OidcAuthorizationCodeAuthenticationProviderOpenID 身份验证。要更改JwtDecoder它使用的,您应该有一个JwtDecoderFactorybean。
例如,您可能有类似的内容:
@Bean
public JwtDecoderFactory<ClientRegistration> customJwtDecoderFactory() {
return new CustomJwtDecoderFactory();
}
static class CustomJwtDecoderFactory implements JwtDecoderFactory<ClientRegistration> {
public JwtDecoder createDecoder(ClientRegistration reg) {
//...
return new CustomJwtDecoder();
}
}
Run Code Online (Sandbox Code Playgroud)
希望这至少能回答您的部分问题。
| 归档时间: |
|
| 查看次数: |
6053 次 |
| 最近记录: |