You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for multiple keys with same kid, which differ just by algorit… - #15114
@stianst@pedroigor Anyone of you is able to review this one please? During investigation of #14794, I figured that we didn't have proper support for the JWKS with multiple keys of same kid (where those keys with same kid differ by algorithm).
So the issue #14794 is a regression, but it worked before likely just by accident (it looks the right key was accidentally chosen in Keycloak 18 for the particular user's scenario, which stopped working due some refactoring done in Keycloak 19 because of some work done on #11036 )
@mposolda, the current fix appears to use the combination of "kid" and "alg" to identify a key within a JWKS which is an improvement.
But what if a JWKS has a set of keys with the same "kid" and "alg" but differing "use" and "kty" ?
It appears from the standard that this is valid: https://www.rfc-editor.org/rfc/rfc7517#section-4.4
@mposolda, the current fix appears to use the combination of "kid" and "alg" to identify a key within a JWKS which is an improvement. But what if a JWKS has a set of keys with the same "kid" and "alg" but differing "use" and "kty" ? It appears from the standard that this is valid: https://www.rfc-editor.org/rfc/rfc7517#section-4.4
@martin-scheelke Good point and I was also thinking about this before. However:
The case with 2 keys with same kid and alg, but different kty should not be possible. As when you have 2 keys with same kid and alg, then they should also have same kty in the case of valid JWKS. For example assume that you have keys with kid abc and algorithm RS256, then the kty should be RSA for both of them.
The case with 2 keys with same kid and alg, but different use is possible in theory. However this would be fine as both ClientPublicKeyLoader and OIDCIdentityProviderPublicKeyLoader takes the use into consideration and already filters the keys by use .
@mposolda, the current fix appears to use the combination of "kid" and "alg" to identify a key within a JWKS which is an improvement. But what if a JWKS has a set of keys with the same "kid" and "alg" but differing "use" and "kty" ? It appears from the standard that this is valid: https://www.rfc-editor.org/rfc/rfc7517#section-4.4
@martin-scheelke Good point and I was also thinking about this before. However:
The case with 2 keys with same kid and alg, but different kty should not be possible. As when you have 2 keys with same kid and alg, then they should also have same kty in the case of valid JWKS. For example assume that you have keys with kid abc and algorithm RS256, then the kty should be RSA for both of them.
The case with 2 keys with same kid and alg, but different use is possible in theory. However this would be fine as both ClientPublicKeyLoader and OIDCIdentityProviderPublicKeyLoader takes the use into consideration and already filters the keys by use .
@mposolda Sounds ok. The "kid"/"alg" combination will solve our immediate problem anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…hm in the JWKS
Closes #14794
@stianst @pedroigor Anyone of you is able to review this one please? During investigation of #14794, I figured that we didn't have proper support for the JWKS with multiple keys of same
kid(where those keys with samekiddiffer by algorithm).So the issue #14794 is a regression, but it worked before likely just by accident (it looks the right key was accidentally chosen in Keycloak 18 for the particular user's scenario, which stopped working due some refactoring done in Keycloak 19 because of some work done on #11036 )