-
Notifications
You must be signed in to change notification settings - Fork 6k
ClientRegistrations#fromIssuerLocation should have shorter (or configurable) Http Connect/Read timeouts #11197
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
Hi @Kehrlann! I think this is closely related to gh-8882, which aims to solve this for a variety of components in the OAuth 2.0 landscape. See ClientRegistrations section, which states:
So it does seem that while there are a number of components that may require customizing the
Based on a quick check the code, it seems there are only something like 5 dynamic properties: |
Not exposing the underlying http client makes sense 👌 In the general case, I think the k8s-based case I mentioned above can be a real problem for users, as something that works on your local dev machine may have different network config in your target k8s cluster, and so you may end up with a difficult to debug situation. Spring Boot uses that utility class for autoconfig, and so I think the general UX would be better (for edge cases) with smaller timeouts.
We use We do want to provide it as a configuration mechanism, rather than asking our users to spell out all of the data:
Our solutions with the current setup would be to get inspiration from the OIDC auto-config in spring-security and reimplement |
Thanks @Kehrlann, I see your point. I only worry about how to manage a decision like this among many other parts of the code base that utilize RestTemplate or WebClient. Would we need to apply this on a wider scale? If you want to take a crack at a PR to adjust the timeouts I don’t think it can hurt to see what it looks like. Do you want to try your hand at it? |
@sjohnr here's the PR - #11232 . I have not added tests - I am unsure where they would go, and I'm unsure how to tweak the values in the test so that they fail faster than 10s. I've looked into the
Note: since the default rest template uses |
This works perfectly for my use-case, thanks! Closing this in favor of possible changes outlined in #8882 . |
Expected Behavior
When using
ClientRegistrations.fromIssuerLocation("http://192.0.2.0")
or any non-responding address[1], the http connect timeout should be "reasonable", in seconds so that users get quick feedback when a issuerUri just doesn't respond. Reasonable may be somewhere between 5 and 10s.Or the
ClientRegistrations.rest
RestTemplate could be configurable.Current Behavior
The current timeout is whatever the default timeout is for RestTemplate / underlying HTTP client implementation. In a "default" Boot application, that timeout is 75s. This means the application will hang for 75 seconds, and Tomcat won't even start up.
That is too long in certain contexts, e.g. a Boot app deployed to Kubernetes. The app would take 75 seconds to respond, which could be longer than the user's readiness probe - the pod would get thrashed without giving useful information to the user.
Context
We have seen this issue in k8s deployments, where our pods would crash because a DNS record was (incorrectly) changed and an OIDC issuer did not respond anymore.
Sample
A Boot app with OAuth2 login enabled, and the following config:
This can be reproduced programmatically by calling
ClientRegistrations.fromIssuerLocation("http://192.0.2.0");
Happy to contribute a PR.
Footnotes
[1] Used
192.0.2.0
as RFC5737 - IPv4 Address Blocks Reserved for Documentation, works as an example for MacOS but I haven't tried on other systems.The text was updated successfully, but these errors were encountered: