-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[SecurityBundle] refresh JWKS on kid mismatch during OIDC discovery #62355
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
[SecurityBundle] refresh JWKS on kid mismatch during OIDC discovery #62355
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
a938bec to
e3626e0
Compare
e3626e0 to
b778601
Compare
|
The authorization server (OP) should always provide a max-age of the JWKs document and the client should strictly adhere to that value. If the OP wants to rotate its keys, it must publish the new keys well before they are used to sign tokens and should only remove their current keys after they are sure that every previously issued token has expired. If the RP reloads the JWKs document everytime an unknown In my opinion the RP must trust the key rotation behaviour of the OP. The OidcTokenHandler should be updated to cache the JWKs document for the duration the OP suggests. Currently the default cache ttl is always used. The only valid point I could come up with is that in case the OP is forced to revoke their keys (e.g. private key was leaked), the RP might not know about the OPs new key yet and reject the token. This is a known limitation of JWTs and boils down to the same problem that already issued JWTs can not be revoked. I strongly urge to close this PR and instead focus on caching the JWKs document with the OPs provided cache instructions. |
Makes sense thanks for the comment, anyone up for a PR doing so? |
|
Thanks for proposing, I'm closing per @danielburger1337's rationale. |
|
Indeed, my intention was to cover the case where an OIDC provider might rotate or revoke signing keys unexpectedly, which can lead to token verification issues. That said, I completely understand and agree with the rationale, following the provider’s cache headers is the correct and standards-compliant approach. I might explore a follow-up PR implementing proper JWKS caching based on those headers, as suggested. Thanks a lot for the explanations and the constructive discussion |
This PR adds an optional refresh_jwks_on_kid_mismatch option to the OIDC discovery mechanism.
When enabled, Symfony will automatically refresh the JWKS if the kid (Key ID) in the JWT header
is not found in the cached key set.
This prevents token validation failures in cases where the OIDC provider’s signing keys
have changed while the cached key set has not yet expired.
Example configuration: