-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWT API: Offer a "strict audience" mode? #894
Comments
Hi @jpadilla, any thoughts on this? Would be great to have this downstream. |
I am positive for this, but open to know others opinion too |
@woodruffw yeah let's do it, what you're proposing sounds good. @di thanks for the bump. |
Great, thanks @jpadilla! I'll have some time this week to make a PR for this. |
Opened #902 for this! |
Thanks a ton @jpadilla! Any chance of a release for this new API surface? Otherwise I'm happy to wait, just figured I'd ask 🙂 |
Shipped v2.8.0 🎉 |
Thanks a ton! |
Hello again!
I'm raising this as a potential feature request for the current
jwt.decode
API.Current behavior
The current
audience
is anOptional[Union[str, Iterable[str]]]
. If a singleaudience
value is passedverify_aud=True
is passed, then the underlying API does the following:aud
is astr
, create a working audience list of[aud]
aud
is aList[str]
, use it as the working audience listaudience
is included in the audience listThis is the right behavior in some JWT applications, but not in all. In particular, some JWT users may prefer to have "strict" audience checking, where passing in a single
str
means that theaud
claim must also be a singlestr
that exactly matches.Proposed behavior
I propose the addition of an
"strict_aud"
(or"exact_aud"
) option in theoptions
kwarg that gets passed intojwt.decode
. When present and set toTrue
, this should change the behavior as stated above: rather than constructing an internal audience list, it should enforce that theaud
claim is only a singlestr
that exactly matches the providedaudience
.See pypi/warehouse#13887 for some justification for this new behavior.
If you're interested in this, let me know and I'd be happy to implement it!
The text was updated successfully, but these errors were encountered: