-
-
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
Resolved issue #205, Allow a list of valid audiences to be configured #246
Conversation
…nfigured Added test cases to check if audience is provided a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few minor changes and this should be good to merge.
CHANGELOG.md
Outdated
@@ -12,6 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
- Better error messages when using an algorithm that requires the cryptography package, but it isn't available [#230][230] | |||
|
|||
### Fixed | |||
- Allow a list of valid audiences to be configured [#205][205] | |||
|
|||
[v1.4.3][1.4.3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add this version section here. We do that whenever we make new releases.
jwt/api_jwt.py
Outdated
raise TypeError('audience must be a string or None') | ||
if not isinstance(audience, (string_types, type(None), list)): | ||
if not isinstance(audience, list): | ||
raise TypeError('audience must be a string or None') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving this all into self._validate_aud()
?
That would probably simplify the implementation a little bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it looks like you basically already did that for the most part. Maybe we should just get rid of the redundant check here completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
CHANGELOG.md
Outdated
@@ -12,6 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
- Better error messages when using an algorithm that requires the cryptography package, but it isn't available [#230][230] | |||
|
|||
### Fixed | |||
- Allow a list of valid audiences to be configured [#205][205] | |||
|
|||
[v1.4.3][1.4.3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically add the new version section when we do a release. We can probably delete these lines for now and leave it up to the maintainers at release time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hi Mark Adams, Thanks for review. I took care of your comments. Could you please review? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. There's a few changes I'd like to see.
Also, please be sure to add this to the CHANGELOG.
if isinstance(audience, string_types): | ||
audience = [audience] | ||
|
||
if not isinstance(audience, list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more idiomatic to try to iterate over the object and handle the exception if it's not iterable.
raise InvalidAudienceError('Invalid audience format') | ||
|
||
for aud in audience: | ||
if aud in audience_claims: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are now checking multiple values to see if they are in audience_claims
do you think it might make more sense to make audience_claims
a set?
Closed by #306 |
Added test cases to check if audience is provided a list.