-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot override WebClient for NimbusReactiveJwtDecoder in ReactiveOidcIdTokenDecoderFactory #14178
Comments
I believe it is already possible: @Bean
ReactiveJwtDecoder jwtDecoder() {
return NimbusReactiveJwtDecoder.withIssuerLocation("https://example.org/issuer")
.webClient(web).build();
} or @Bean
ReactiveJwtDecoder jwtDecoder() {
return NimbusReactiveJwtDecoder.withJwkSetUri("https://example.org/jwks")
.webClient(web).build();
} Are you having trouble with either of these approaches? |
Hi @jzheaux, the problem is not wit NimbusReactiveJwtDecoder itself, but rather one that is created within ReactiveOidcIdTokenDecoderFactory. There is no way to pass WebClient to that specific instance, which is not created by myself and cannot be easily overriden due to private methods all around ... |
I see, sorry that I missed that. I think it would be reasonable to add a method to public void setWebClientFactory(Function<ClientRegistration, WebClient> webClientFactory) {
// ...
} Are you able to provide a PR to add that to |
Hi @jzheaux, I may be able to do it during the oncoming holidays. |
I don't think we should enhance Furthermore, given that we will eventually provide support for the new |
Closed in favor of #14357 |
Based on this comment as well as the simplicity of this construction, I think the following arrangement is preferred: @Component
public class MyJwtDecoderFactory implements JwtDecoderFactory<ClientRegistration> {
@Cacheable
public JwtDecoder createDecoder(ClientRegistration registration) {
String issuerUri = client.getProviderDetails().getIssuerUri();
NimbusJwtDecoder decoder = NimbusJwtDecoder.withIssuerLocation(issuerUri).restOperations(this.rest).build();
decoder.setJwtValidator(new DelegatingOAuth2TokenValidator<>(
JwtValidators.createDefault(), new OidcIdTokenValidator(client)));
decoder.setClaimTypeConverter(
new ClaimTypeConverter(OidcIdTokenDecoderFactory.createDefaultClaimTypeConverters()));
return decoder;
}
} Also, recent 6.3 changes will simplify this to: @Component
public class MyJwtDecoderFactory implements JwtDecoderFactory<ClientRegistration> {
@Cacheable
public JwtDecoder createDecoder(ClientRegistration registration) {
String issuerUri = client.getProviderDetails().getIssuerUri();
NimbusJwtDecoder decoder = NimbusJwtDecoder.withIssuerLocation(issuerUri).restOperations(this.rest).build();
decoder.setJwtValidator(JwtValidators.createDefaultWithValidators(new OidcIdTokenValidator(client)));
decoder.setClaimTypeConverter(OidcIdTokenDecoderFactory.createDefaultClaimTypeConverter());
return decoder;
}
} As such, I think we should revert the |
Hi @jzheaux, For info, i am not a OIDC expert so please double check what I am saying just after 😃 Customizing the The I was very happy with #14357 merge. It is sad that was reverted because in my case the only solution I see right now is copy pasting the ReactiveOidcIdTokenDecoderFactory tweaking the class as you initially proposed. Do you think it can be added back ? |
Expected Behavior
As the title says ... the NimbusReactiveJwtDecoder is created with default web client initialized statically. There is no way to change it. It should be possible to change the WebClient passed to NimbusReactiveJwtDecoder.
Current Behavior
Compared to other parts of the reactive stack, it is currently impossible to customize WebClient passed to NimbusReactiveJwtDecoder
Context
I have a Keycloak instance behind a self-signed SSL certificate. I have configured webclient instance to get it using WebClientSsl builder. But I can't pass that WebClient to NimbusReactiveJwtDecoder.
The text was updated successfully, but these errors were encountered: