Skip to content

Ignore unsupported kty when a Set is built from an array (RFC 7517 §5)#744

Open
RalphBragg wants to merge 1 commit into
jwt:mainfrom
RalphBragg:fix/jwks-set-array-ignore-unknown-kty
Open

Ignore unsupported kty when a Set is built from an array (RFC 7517 §5)#744
RalphBragg wants to merge 1 commit into
jwt:mainfrom
RalphBragg:fix/jwks-set-array-ignore-unknown-kty

Conversation

@RalphBragg

Copy link
Copy Markdown

What

Makes JWT::JWK::Set.new(array_of_keys) skip a key whose kty it does not recognise, instead of raising JWT::UnsupportedKeyType and failing the whole set.

Why

The Hash constructor already does this (added in #728, "Ignore unknown algorithm jwks per RFC 7517"), but the Array branch of Set#initialize still did jwks.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 on main thanks to #728; this closes the array-input gap.)

Change

  • Set#initialize Array branch now uses the same each_with_object + rescue JWT::UnsupportedKeyType pattern as the Hash branch.
  • Added a spec mirroring the existing Hash-case test.

spec/jwt/jwk/set_spec.rb passes (20 examples, 0 failures).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant