Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Align NimbusJwtDecoder HTTP timeout defaults with Nimbus by setting to 500ms #17669

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

Merged
jzheaux merged 1 commit into spring-projects:main from frido37:main
Sep 2, 2025

Conversation

Copy link

@frido37 frido37 commented Aug 7, 2025

Summary
This change proposes a potential fix for spring-security#15866, which we encountered in a production environment.

Problem
We experienced a critical "stop-the-world" event lasting approximately 15 minutes due to the absence of connection and read timeouts in the default RestTemplate configuration used by NimbusJwtDecoder. Specifically, the underlying SimpleClientHttpRequestFactory does not define any timeouts, which can cause the application to hang indefinitely in certain network failure scenarios.

Current Workaround
To mitigate this in our own application, we use a JwkSetUriJwtDecoderBuilderCustomizer to configure the RestTemplate with appropriate timeouts. While this works, the current default behavior is problematic and may impact other users as well.

@Configuration
public class JwtDecoderConfig {
 @Bean
 public JwkSetUriJwtDecoderBuilderCustomizer jwkSetUriJwtDecoderBuilderCustomizer() {
 return builder -> {
 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
 requestFactory.setConnectTimeout(RemoteJWKSet.DEFAULT_HTTP_CONNECT_TIMEOUT);
 requestFactory.setReadTimeout(RemoteJWKSet.DEFAULT_HTTP_READ_TIMEOUT);
 builder.restOperations(new RestTemplate(requestFactory));
 };
 }
}

Proposal
We suggest that reasonable default timeouts (both connect and read) should be applied to the RestTemplate used by default in NimbusJwtDecoder. This change will help prevent similar problems for others.

Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @frido37, for the PR! I've left some feedback inline.

Copy link
Contributor

jzheaux commented Aug 13, 2025

This is a note for myself:

As part of merging, upgrade instructions should be added to the 6.5 guide for how to update an application's configuration to use the new timeout values. In this way, they can know whether the new timeouts will be an issue before updating to 7.0.

@jzheaux jzheaux self-assigned this Aug 13, 2025
@jzheaux jzheaux added status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 13, 2025
@jzheaux jzheaux changed the title (削除) Add timeout parameter to critical remote http call in mutex section (削除ここまで) (追記) Align NimbusJwtDecoder HTTP timeout defaults with Nimbus by setting to 500 ms (追記ここまで) Aug 13, 2025
@jzheaux jzheaux changed the title (削除) Align NimbusJwtDecoder HTTP timeout defaults with Nimbus by setting to 500 ms (削除ここまで) (追記) Align NimbusJwtDecoder HTTP timeout defaults with Nimbus by setting to 500ms (追記ここまで) Aug 13, 2025
Copy link
Author

frido37 commented Aug 18, 2025

Thanks for the feedback. I Resolved it with the second commit.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 18, 2025
@jzheaux jzheaux removed the status: feedback-provided Feedback has been provided label Aug 21, 2025
Copy link
Contributor

jzheaux commented Aug 22, 2025
edited
Loading

Thanks, @frido37. Will you please squash your commits and then we can merge it?

In the future, if you publish a PR on a branch instead of main, I can help a bit more with cleanups like that.

Please also change your commit to the following title and description:

Provider Default Timeouts For JWK Retrieval
Issue gh-14269

@jzheaux jzheaux added the status: waiting-for-feedback We need additional information before we can continue label Aug 22, 2025
Issue spring-projectsgh-14269
Signed-off-by: Fridolin Jackstadt <fridolin.jackstadt@unic.com>
Copy link
Author

frido37 commented Aug 23, 2025

I’ve squashed the commits and updated the commit message. Let me know if anything else is needed.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 23, 2025
@jzheaux jzheaux added this to the 7.0.0-M3 milestone Aug 26, 2025
@jzheaux jzheaux merged commit 910df47 into spring-projects:main Sep 2, 2025
6 checks passed
Copy link
Contributor

jzheaux commented Sep 2, 2025

Thanks, @frido37! This has been merged into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@jzheaux jzheaux jzheaux approved these changes

Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Milestone
7.0.0-M3
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /