Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ignore unknown kty in KeySet.import_key_set (RFC 7517 §5)#103

Open
RalphBragg wants to merge 1 commit into
authlib:mainauthlib/joserfc:mainfrom
RalphBragg:fix/jwks-import-ignore-unknown-ktyRalphBragg/joserfc:fix/jwks-import-ignore-unknown-ktyCopy head branch name to clipboard
Open

Ignore unknown kty in KeySet.import_key_set (RFC 7517 §5)#103
RalphBragg wants to merge 1 commit into
authlib:mainauthlib/joserfc:mainfrom
RalphBragg:fix/jwks-import-ignore-unknown-ktyRalphBragg/joserfc:fix/jwks-import-ignore-unknown-ktyCopy head branch name to clipboard

Conversation

@RalphBragg

Copy link
Copy Markdown

What

KeySet.import_key_set now skips a key whose kty is present but not in the registry, instead of raising InvalidKeyTypeError and failing the whole set.

Why

Today import_key_set imports each key eagerly, so the first key with an unrecognised kty raises (Invalid key type: '...') and the entire set fails. 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) begin appearing in published JWKS next to RSA/EC keys: one unknown key otherwise stops the classical keys next to it from verifying. (Companion to the same fix in authlib, authlib/authlib#914, since authlib.jose points here as its successor.)

Change

  • import_key_set skips only keys whose kty is explicitly present and not in registry_cls.key_types; a recognised-but-malformed key still raises, and a set with no usable keys still raises MissingKeyError as before.
  • Added test_import_key_set_ignores_unknown_kty.

tests/jwk/test_jwk_set.py passes (11 passed).

import_key_set raised InvalidKeyTypeError on the first key whose kty was not
in the registry, failing the whole set. Skip a key whose kty is present but
unrecognised, per RFC 7517 Section 5, so classical keys published alongside a
post-quantum key (ML-DSA, kty AKP) remain usable.
@RalphBragg

Copy link
Copy Markdown
Author

Tracking issue: #104. This PR fixes it.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.