Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

codervinod
Copy link

Added test cases to check if audience is provided a list.

…nfigured

Added test cases to check if audience is provided a list.
Copy link
Contributor

@mark-adams mark-adams left a 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]
Copy link
Contributor

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')
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Author

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]
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codervinod
Copy link
Author

Hi Mark Adams,

Thanks for review. I took care of your comments. Could you please review?

Thanks.
Vinod

Copy link
Contributor

@mark-adams mark-adams left a 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):
Copy link
Contributor

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:
Copy link
Contributor

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?

@jpadilla
Copy link
Owner

Closed by #306

@jpadilla jpadilla closed this Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants