-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
401 for OIDC WEB_APP when kid is not found #45582
Comments
/cc @pedroigor (oidc), @sberyozkin (oidc) |
@antoniomacri Thanks for providing the logs, indeed, the verification sequence, as confirmed by the logs (and is consistent with how Vert.x OIDC does it as well) is as follows:
The failure happens at step 3, your IDP returns Please check a couple of things:
Also, FYI, the discovery is enabled by default so enabling it explicitly is not required. The |
Hi @sberyozkin, thank you for the quick response!
Thanks for the hints on defaut configs, but I'm not using the What do you think about the three possibile ways I mentioned above to handle the failure? |
Hi @antoniomacri, yes, I meant in Refreshing the tokens without verifying signatures seems risky... I'm not sure right now, it requires some thinking... |
@antoniomacri Is it the case that when the ID token has non-matching kid, this ID token has already expired ? For example if JWKS are rotated every 12 hours then the ID token which was issued 13 hours back and therefore will have no matching kid, was only valid for 12 hours ? |
I can also think of one workaround: add |
Yes, typically the ID token is expired when the kid is not found, since it lasts in minutes to hour (I don't remember exactly but I could check if you think it's helpful).
It seems that the Set-Cookie is ignored on 302 by some clients (including curl and IDEA REST client). So, if the possibility to refresh the tokens is excluded, I think the only workaround is returning a 401 with HTML refresh... |
I'd not be concerned about it, curl (which is CLI tool) or IDEA REST client is not what Quarkus OIDC
May be it can done optionally, with the configuration (like refresh when no matching key is available...)
This is what the custom ExceptionMapper workaround mentioned above can do, to prepare a specific type of response.... I believe you can make it work right now, can you please experiment ? |
Hi @sberyozkin, as you suggested I tried with 302 and it seems to work on most browsers. Also 401 with HTML redirect works. I'll experiment a bit and see if there is any side effect on our apps.
I didn't dig deeper, but that seems a good fallback to me. Thanks! |
Hi @antoniomacri Thanks, I think for the specific verification failure related to a non-matching key, we can indeed redirect by default. So, yes, I'll just do 302 if no matching key is available for users to re-authenticate. Thanks |
@antoniomacri FYI, #45659 |
Hi @antoniomacri, this PR will be merged shortly, FYI, at the moment this 302 redirect is optional, not enabled by default, given an overall sensitivity related to the situation where a token whose signature can not be verified due to an unresolved key causes the re-authentication. It makes quite a perfect sense in your case, but it making it a default behavior for any session token which for some reasons does not have a matching key, appears to be somewhat risky. Thanks |
Fixed by #45659 |
Describe the bug
Hi have the following configuration:
My IdP is configured to rotate keys in the JWKS every 12 hours. After some time, the key is removed from the JWKS endpoint.
When a user tries to refresh an old page (for instance it has a tab in the browser from the previous day), as a consequence of the key not present in the JWKS, the client obtains a 401:
Expected behavior
Since the OIDC extension is configured as a WEB_APP, I do not expect a plain 401. I would expect either (obviously after the cookie reset which is already done):
Actual behavior
The OIDC extension returns a 401 and the user (yes, business user which doesn't bother clicking F5 on the browser) perceives the application is not working.
How to Reproduce?
I don't have a reproducer, since I cannot share the IdP. However, these are the logs:
Output of
uname -a
orver
No response
Output of
java -version
Java version: 21.0.5, vendor: Oracle Corporation
Quarkus version or git rev
3.17.6
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Additional information
No response
The text was updated successfully, but these errors were encountered: