-
Notifications
You must be signed in to change notification settings - Fork 6k
OAuth: factory methods in JwtDecoders does not allow changing timeout #9904
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
Comments
Just faced the same issue. For some reason I reach the timeout at home and I cannot update the timeout for my local environment without rewriting what |
Hi, @IsSkyfalls, thanks for the suggestion. Setting timeouts is a reasonable thing to want to do. That said, it wouldn't make sense to pass in a Instead, you can use If that doesn't help enough, will you please share the boilerplate that you are having trouble simplifying? |
Thanks for the help! NimbusJwtDecoder's builders are basically what I have suggested. Guess that's an RTFM for me. |
I am personally not convinced. Yes |
Much of the code in For example, if you know what your JWK Set URI and supported algorithms are, the code goes from this: @Bean
JwtDecoder jwtDecoder() {
return JwtDecoders.withIssuerLocation(issuerUri);
} to this: @Bean
JwtDecoder jwtDecoder() {
NimbusJwtDecoder jwtDecoder = NimbusJwtDecoders.withJwkSetUri(jwkSetUri)
.algorithms((algs) -> algs.addAll(...)).build();
jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(issuerUri));
return jwtDecoder;
} So, I'm not seeing why this is sad. @aheritier can you elaborate on what is tricky about your use case? |
@jzheaux The code change is effectively not difficult to do and we are effectively talking about 1 lines vs 3 lines of code. |
I wonder if this is a good point at which to introduce |
it might be great @jzheaux but let's honest if we are only 2 to report the issue, it's not necessarily important. |
I came across this discussion while migrating from Keycloak to Auth0. I guess once you have resolved your security config issues, you don't revisit them very often. Was surprised to find hard coded constants and lack of support to inject standard spring managed beans to create the desired behaviour. Even if |
Expected Behavior
Factory methods in JwtDecoders should accept timeout values to pass into RemoteJWKSet.
Current Behavior
Well, it doesn't allow this.
Problem:
JwtDecoders
has 2 factory methods,fromIssuerLocation
andwithProviderConfiguration
. Which both initializeRemoteJWKSet
with only thejwkSetURL
parameter. Because theresourceRetriever
parameter is not set, it initializes with the default timeouts which are 500ms for both http_read and http_connect. Only 1 second is a bit short and just fail on my slow school wifi because SSL handshake took 2 seconds on its own.Solution:
I could just stop using
JwtDecoders
and createJwtDecoder
myself. This is like 15 lines of boilerplate code. But I think this should be customizable inJwtDecoders
. The thing is, based on the current design(factory methods), I really couldn't find a proper place to pass inRemoteJWKSet
or its parameters. Maybe a builder pattern is more appropriate in this situation?The text was updated successfully, but these errors were encountered: