Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(core): JWK Thumbprint URI (RFC 9278) - #733

Merged
Spomky merged 1 commit into
4.3.xfrom
feat/jwk-thumbprint-uri
Sep 13, 2026
Merged

feat(core): JWK Thumbprint URI (RFC 9278)#733
Spomky merged 1 commit into
4.3.xfrom
feat/jwk-thumbprint-uri

Conversation

@Spomky

@Spomky Spomky commented Sep 13, 2026

Copy link
Copy Markdown
Member

Closes #725

What

RFC 9278 names a key by its RFC 7638 thumbprint: urn:ietf:params:oauth:jwk-thumbprint:<hash-alg>:<thumbprint>. It is the key-based sub / kid of OAuth DPoP, SIOP v2, OpenID for Verifiable Credentials and OpenID Federation.

  • Jose\Component\Core\JwkThumbprintUrifinal readonly value object: fromKey(JWK, $hashAlgorithm = 'sha-256'), parse($uri), isValid($uri), hashAlgorithms(), hashAlgorithm(), thumbprint(), matches(JWK) (constant-time), toString() / __toString(). It carries the IANA → PHP hash-name mapping (sha-256, sha-384, sha-512, sha3-224, sha3-256, sha3-384, sha3-512). Any other name — md5, the PHP spelling sha256, the truncated sha-256-128, blake2b-256 that PHP cannot compute — throws UnsupportedAlgorithmException; a malformed URI throws InvalidArgumentException.
  • JWK::thumbprintUri(string $hashAlgorithm = 'sha-256'): string. The RFC 7638 computation is not duplicated: it calls thumbprint(), so the AKP case of feat(signature): ML-DSA-44/65/87 and the AKP key type via OpenSSL 3.5 (RFC 9964) #723 flows through.
  • JWKSet::selectKeyByThumbprintUri(string|JwkThumbprintUri $uri): ?JWK — verifier-side lookup. A dedicated method rather than a selectKey() restriction, since the URI is not a key member and selectKey() compares members. A key whose thumbprint cannot be computed is skipped, as selectKey() does with malformed keys.
  • key:thumbprint --uri--hash then takes the IANA name; the PHP names of the supported functions are translated so the existing default sha256 works in both modes.

Acceptance criteria

  • RFC 9278 §3 example (RFC 7638 §3.1 RSA key, sha-256) → urn:ietf:params:oauth:jwk-thumbprint:sha-256:NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs
  • sha-512 and sha3-256 URIs produced and parsed (values pinned in the tests); md5 and unknown names refused ✔
  • JWKSet lookup returns the matching key, null otherwise ✔

Tests

tests/Component/Core/JwkThumbprintUriTest.php (41 tests) and 7 new key:thumbprint cases in tests/Component/Console/KeyConversionCommandTest.php. PHPUnit, ECS, PHPStan (no baseline change), Rector and Deptrac are green.

Out of scope

DPoP / SIOP / OID4VC logic, and what thumbprint() hashes (#723).

Documentation: web-token/jwt-doc.

RFC 9278 names a key by its RFC 7638 thumbprint:
"urn:ietf:params:oauth:jwk-thumbprint:<hash-alg>:<thumbprint>". It is
the key-based "sub" or "kid" of OAuth DPoP, SIOP v2, OpenID for
Verifiable Credentials and OpenID Federation, and every implementer of
those profiles had to build and parse it by hand.

JwkThumbprintUri is the value object: fromKey(), parse(), matches() and
the accessors. It carries the mapping between the IANA "Named
Information Hash Algorithm" names the URI uses ("sha-256") and the
names PHP gives to the same functions ("sha256"), so that neither side
has to know it. Only the registered names PHP can compute are accepted;
truncated variants, BLAKE2, KangarooTwelve and non-registered names
("md5", "sha256") are refused with UnsupportedAlgorithmException. The
RFC 7638 computation is not duplicated: it goes through
JWK::thumbprint(), so the AKP case of #723 will flow through.

JWK::thumbprintUri() produces the URI and
JWKSet::selectKeyByThumbprintUri() is the verifier-side lookup. It is a
dedicated method rather than a restriction of selectKey(): the URI is
not a member of the key, and selectKey() compares members. As in
selectKey(), a key whose thumbprint cannot be computed is skipped.

key:thumbprint gains a "--uri" option. "--hash" then takes the IANA
name, and the PHP names of the supported functions are translated so
that the existing default "sha256" keeps working in both modes.

Closes #725
@Spomky Spomky self-assigned this Sep 13, 2026
@Spomky Spomky added this to the 4.3.0 milestone Sep 13, 2026
@Spomky
Spomky merged commit 6f4b9c4 into 4.3.x Sep 13, 2026
17 checks passed
@Spomky
Spomky deleted the feat/jwk-thumbprint-uri branch September 13, 2026 11:32
Spomky added a commit to web-token/jwt-doc that referenced this pull request Sep 13, 2026
web-token/jwt-framework#733 adds JwkThumbprintUri, JWK::thumbprintUri(),
JWKSet::selectKeyByThumbprintUri() and the "--uri" option of
key:thumbprint. The key page gains a "Thumbprint URI" section with the
IANA hash names, the key set page the lookup, the console page the
option with a verified example; RFC 9278 joins the feature lists and
the 4.2 → 4.3 guide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): JWK Thumbprint URI (RFC 9278)

1 participant