Repository navigation
feat(jwk): add RFC 7638 thumbprint calculation to PyJWK - #1232
Open
saadkhantareen wants to merge 1 commit into
Open
saadkhantareen wants to merge 1 commit into
saadkhantareen wants to merge 1 commit into
Conversation
auvipy
self-requested a review
October 15, 2026 12:34
This branch has not been deployed
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.
Summary
Add
PyJWK.thumbprint()to compute the JWK thumbprint defined by RFC 7638. This was requested in #1032 and is needed for protocols such as DPoP (RFC 9449), which identify keys by their JWK thumbprint.Changes
PyJWK.thumbprint(hash_algorithm="SHA-256")injwt/api_jwk.py: builds the JSON object containing only the members required for the key'skty(EC:crv,kty,x,y; OKP:crv,kty,x; RSA:e,kty,n; oct:k,kty), serializes it with members in lexicographic order and no whitespace, hashes it, and returns the Base64URL-encoded digest without padding. Members such askid,algandusedo not affect the result.InvalidKeyErrorwhen the key type is unsupported or a required member is missing, andValueErrorfor an unknown hash algorithm.Tests
python -m pytest tests/test_api_jwk.py -q— 29 passed, 3 skipped (the 3 skips are pre-existing tests for running without thecryptographypackage).NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs.ruff check jwt/api_jwk.py tests/test_api_jwk.py— all checks passed.Fixes #1032