Repository navigation
fix: treat claims option "value" as the expected claim value - #108
Merged
Merged
Conversation
A list passed to the "value" option was wrapped into a nested list
before the membership check, so a claim equal to the configured
value was rejected, e.g.::
JWTClaimsRegistry(aud={"essential": True, "value": ["id1"]}).validate({"aud": ["id1"]})
Compare the claim with the configured value itself: a list claim
matches when it equals the configured value or contains it, and a
scalar claim still has to equal it.
Fixes authlib#107
Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com>
lepture
approved these changes
Oct 23, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
=======================================
Coverage 99.86% 99.86%
=======================================
Files 47 47
Lines 3010 3014 +4
Branches 360 362 +2
=======================================
+ Hits 3006 3010 +4
Misses 2 2
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thanks |
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.
As confirmed in #107, when the "value" option is a list, the claim should match it as a whole. Today the option value gets wrapped into a nested list and only element membership is checked, so this fails:
This PR compares the claim with the configured value itself. A list claim matches when it equals the configured value or contains it (so
audarriving as["id1"]againstvalue: "id1"keeps working), and a scalar claim still has to equal it, so{"aud": "id1"}against{"value": ["id1", "id2"]}keeps raising like before. Thevaluespath is untouched.I also widened the
valuefield inClaimsOption, since a list there is now valid input.Added regression tests for the list shapes. On main the new tests raise
InvalidClaimError; on this branch the full suite result is unchanged apart from them (the jwe chacha20 and okp pem failures also happen on pristine main in my local environment, they are dependency-dependent).