From 22b94859d78c8fd7ec639074cb171558ee57867f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Mar 2018 13:04:35 +0000 Subject: [PATCH 1/4] Add missing links to changelog (#334) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b350dec..8decdd6d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,7 @@ rarely used. Users affected by this should upgrade to 3.3+. [1.5.1]: https://github.com/jpadilla/pyjwt/compare/1.5.0...1.5.1 [1.5.2]: https://github.com/jpadilla/pyjwt/compare/1.5.1...1.5.2 [1.5.3]: https://github.com/jpadilla/pyjwt/compare/1.5.2...1.5.3 +[1.6.0]: https://github.com/jpadilla/pyjwt/compare/1.5.3...1.6.0 [109]: https://github.com/jpadilla/pyjwt/pull/109 [110]: https://github.com/jpadilla/pyjwt/pull/110 @@ -219,4 +220,5 @@ rarely used. Users affected by this should upgrade to 3.3+. [304]: https://github.com/jpadilla/pyjwt/pull/304 [306]: https://github.com/jpadilla/pyjwt/pull/306 [315]: https://github.com/jpadilla/pyjwt/pull/315 +[316]: https://github.com/jpadilla/pyjwt/pull/316 [7c1e61d]: https://github.com/jpadilla/pyjwt/commit/7c1e61dde27bafe16e7d1bb6e35199e778962742 From 9d980786c9080ad99ae221ea5b77397434c3c50c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Mar 2018 13:05:39 +0000 Subject: [PATCH 2/4] Expose InvalidSignatureError on jwt module (#335) Regards jpadilla/pyjwt#316 --- jwt/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jwt/__init__.py b/jwt/__init__.py index 90cd457d9..699e2e093 100644 --- a/jwt/__init__.py +++ b/jwt/__init__.py @@ -25,5 +25,6 @@ InvalidTokenError, DecodeError, InvalidAlgorithmError, InvalidAudienceError, ExpiredSignatureError, ImmatureSignatureError, InvalidIssuedAtError, InvalidIssuerError, ExpiredSignature, - InvalidAudience, InvalidIssuer, MissingRequiredClaimError + InvalidAudience, InvalidIssuer, MissingRequiredClaimError, + InvalidSignatureError, ) From 02374f4203c7ee0e11fdd32c61cb067b63cd0cff Mon Sep 17 00:00:00 2001 From: Derek Weitzel Date: Thu, 15 Mar 2018 10:29:53 -0500 Subject: [PATCH 3/4] Fix bug if application does not specify audience (#336) * Fix bug if application does not specify audience * Update changelog * Fixing blank line * Fixing error message with missing audience --- AUTHORS | 2 ++ CHANGELOG.md | 3 +++ jwt/api_jwt.py | 5 +++++ tests/test_api_jwt.py | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/AUTHORS b/AUTHORS index 2511b2ee9..90c7fa4d8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,3 +25,5 @@ Patches and Suggestions - Michael Davis - Vinod Gupta + + - Derek Weitzel diff --git a/CHANGELOG.md b/CHANGELOG.md index 8decdd6d2..8339f771a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Audience parameter throws `InvalidAudienceError` when application does not specify an audience, but the token does. [#336][336] + ### Added [v1.6.0][1.6.0] @@ -222,3 +224,4 @@ rarely used. Users affected by this should upgrade to 3.3+. [315]: https://github.com/jpadilla/pyjwt/pull/315 [316]: https://github.com/jpadilla/pyjwt/pull/316 [7c1e61d]: https://github.com/jpadilla/pyjwt/commit/7c1e61dde27bafe16e7d1bb6e35199e778962742 +[336]: https://github.com/jpadilla/pyjwt/pull/336 diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py index edef77018..ce1e19766 100644 --- a/jwt/api_jwt.py +++ b/jwt/api_jwt.py @@ -168,6 +168,11 @@ def _validate_aud(self, payload, audience): # verified since the token does not contain a claim. raise MissingRequiredClaimError('aud') + if audience is None and 'aud' in payload: + # Application did not specify an audience, but + # the token has the 'aud' claim + raise InvalidAudienceError('Invalid audience') + audience_claims = payload['aud'] if isinstance(audience_claims, string_types): diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py index 58b47f2c9..8f550cb83 100644 --- a/tests/test_api_jwt.py +++ b/tests/test_api_jwt.py @@ -288,6 +288,15 @@ def test_check_audience_list_when_valid(self, jwt): token = jwt.encode(payload, 'secret') jwt.decode(token, 'secret', audience=['urn:you', 'urn:me']) + def test_check_audience_none_specified(self, jwt): + payload = { + 'some': 'payload', + 'aud': 'urn:me' + } + token = jwt.encode(payload, 'secret') + with pytest.raises(InvalidAudienceError): + jwt.decode(token, 'secret') + def test_raise_exception_invalid_audience_list(self, jwt): payload = { 'some': 'payload', From 285afade1d14eb810615c5bc751ea2c6a7a3314a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Sun, 18 Mar 2018 09:37:23 -0400 Subject: [PATCH 4/4] Bump up version to v1.6.1 --- CHANGELOG.md | 11 ++++++++--- jwt/__init__.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8339f771a..314b5cca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,10 +10,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Audience parameter throws `InvalidAudienceError` when application does not specify an audience, but the token does. [#336][336] - ### Added +[v1.6.1][1.6.1] +------------------------------------------------------------------------- +### Fixed + +- Audience parameter throws `InvalidAudienceError` when application does not specify an audience, but the token does. [#336][336] + [v1.6.0][1.6.0] ------------------------------------------------------------------------- ### Changed @@ -183,6 +187,7 @@ rarely used. Users affected by this should upgrade to 3.3+. [1.5.2]: https://github.com/jpadilla/pyjwt/compare/1.5.1...1.5.2 [1.5.3]: https://github.com/jpadilla/pyjwt/compare/1.5.2...1.5.3 [1.6.0]: https://github.com/jpadilla/pyjwt/compare/1.5.3...1.6.0 +[1.6.1]: https://github.com/jpadilla/pyjwt/compare/1.6.0...1.6.1 [109]: https://github.com/jpadilla/pyjwt/pull/109 [110]: https://github.com/jpadilla/pyjwt/pull/110 @@ -223,5 +228,5 @@ rarely used. Users affected by this should upgrade to 3.3+. [306]: https://github.com/jpadilla/pyjwt/pull/306 [315]: https://github.com/jpadilla/pyjwt/pull/315 [316]: https://github.com/jpadilla/pyjwt/pull/316 -[7c1e61d]: https://github.com/jpadilla/pyjwt/commit/7c1e61dde27bafe16e7d1bb6e35199e778962742 [336]: https://github.com/jpadilla/pyjwt/pull/336 +[7c1e61d]: https://github.com/jpadilla/pyjwt/commit/7c1e61dde27bafe16e7d1bb6e35199e778962742 diff --git a/jwt/__init__.py b/jwt/__init__.py index 699e2e093..823128dc4 100644 --- a/jwt/__init__.py +++ b/jwt/__init__.py @@ -10,7 +10,7 @@ __title__ = 'pyjwt' -__version__ = '1.6.0' +__version__ = '1.6.1' __author__ = 'José Padilla' __license__ = 'MIT' __copyright__ = 'Copyright 2015 José Padilla'