Ignore unsupported kty when a Set is built from an array (RFC 7517 §5)#744
Open
RalphBragg wants to merge 1 commit into
Open
Ignore unsupported kty when a Set is built from an array (RFC 7517 §5)#744RalphBragg wants to merge 1 commit into
RalphBragg wants to merge 1 commit into
Conversation
…ction 5) The Hash constructor already skips keys whose kty is unrecognised (jwt#728), but the Array constructor did not, so JWT::JWK::Set.new([...]) still failed the whole set on one unknown key. Mirror the Hash path so both are tolerant.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Makes
JWT::JWK::Set.new(array_of_keys)skip a key whosektyit does not recognise, instead of raisingJWT::UnsupportedKeyTypeand failing the whole set.Why
The Hash constructor already does this (added in #728, "Ignore unknown algorithm jwks per RFC 7517"), but the
Arraybranch ofSet#initializestill didjwks.map { |k| JWT::JWK.new(...) }with no rescue, so building a set from a bare array of JWKs remained fatal on one unrecognised key.RFC 7517 §5 says a processor SHOULD ignore key types it does not understand. This is becoming a live issue as post-quantum keys (ML-DSA,
kty:"AKP", RFC 9964) start appearing in published key sets: one unknown key otherwise stops the classical keys next to it from working. Relates to #743. (Note: the Hash path is already fine onmainthanks to #728; this closes the array-input gap.)Change
Set#initializeArray branch now uses the sameeach_with_object+rescue JWT::UnsupportedKeyTypepattern as the Hash branch.spec/jwt/jwk/set_spec.rbpasses (20 examples, 0 failures).