Hello community, here is the log from the commit of package python-PyJWT for openSUSE:Factory checked in at 2018-05-29 10:41:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-PyJWT (Old) and /work/SRC/openSUSE:Factory/.python-PyJWT.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-PyJWT" Tue May 29 10:41:18 2018 rev:14 rq:611535 version:1.6.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-PyJWT/python-PyJWT.changes 2018-02-24 16:39:20.133544437 +0100 +++ /work/SRC/openSUSE:Factory/.python-PyJWT.new/python-PyJWT.changes 2018-05-29 10:41:26.184206492 +0200 @@ -1,0 +2,13 @@ +Wed May 23 10:35:21 UTC 2018 - [email protected] + +- Version update to 1.6.3: + * Dropped support for python 2.6 and 3.3 #301 + * An invalid signature now raises an InvalidSignatureError instead of DecodeError #316 + * Fix over-eager fallback to stdin #304 + * Audience parameter throws InvalidAudienceError when application does not specify an audience, but the token does. #336 + * All exceptions inherit from PyJWTError #340 + * Add type hints #344 + * Add help module 7ca41e5 +- Drop pointless _service file + +------------------------------------------------------------------- Old: ---- PyJWT-1.5.3.tar.gz _service New: ---- PyJWT-1.6.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-PyJWT.spec ++++++ --- /var/tmp/diff_new_pack.xrj5hW/_old 2018-05-29 10:41:27.828145812 +0200 +++ /var/tmp/diff_new_pack.xrj5hW/_new 2018-05-29 10:41:27.828145812 +0200 @@ -18,32 +18,27 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-PyJWT -Version: 1.5.3 +Version: 1.6.3 Release: 0 Summary: JSON Web Token implementation in Python License: MIT Group: Development/Languages/Python -Url: https://github.com/progrium/pyjwt +URL: https://github.com/progrium/pyjwt Source: https://files.pythonhosted.org/packages/source/P/PyJWT/PyJWT-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build - -BuildRequires: %{python_module cryptography} +BuildRequires: %{python_module cryptography >= 1.4} BuildRequires: %{python_module devel} +BuildRequires: %{python_module ecdsa} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: dos2unix BuildRequires: fdupes BuildRequires: python-rpm-macros - -Requires: python-cryptography +Requires: python-cryptography >= 1.4 Requires: python-ecdsa Requires: python-setuptools - Requires(post): update-alternatives Requires(postun): update-alternatives - BuildArch: noarch - %python_subpackages %description @@ -56,7 +51,7 @@ %build %python_build #remove shebang from all non executable files -find ./ -type f -name "*.py" -perm 644 -exec sed -i -e '1{\@^#!/usr/bin/env python@d}' {} \; +find ./ -type f -name "*.py" -perm 644 -exec sed -i -e '1{\@^#!%{_bindir}/env python@d}' {} \; %install %python_install @@ -72,11 +67,11 @@ %python_uninstall_alternative pyjwt %check -%{python_expand PYTHONPATH=%{buildroot}%{python_sitelib} py.test-%{py_ver} -o addopts="" -k "not test_verify_false_deprecated" } +%{python_expand PYTHONPATH=%{buildroot}%{python_sitelib} py.test-%{$python_version} -o addopts="" -k "not test_verify_false_deprecated" } -%files %python_files -%defattr(-,root,root,-) -%doc AUTHORS CHANGELOG.md LICENSE README.rst +%files %{python_files} +%license LICENSE +%doc AUTHORS CHANGELOG.md README.rst %{python_sitelib}/* %python_alternative %{_bindir}/pyjwt ++++++ PyJWT-1.5.3.tar.gz -> PyJWT-1.6.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/AUTHORS new/PyJWT-1.6.3/AUTHORS --- old/PyJWT-1.5.3/AUTHORS 2015-05-30 16:21:11.000000000 +0200 +++ new/PyJWT-1.6.3/AUTHORS 2018-03-18 14:35:35.000000000 +0100 @@ -23,3 +23,7 @@ - Wouter Bolsterlee <[email protected]> - Michael Davis <[email protected]> <[email protected]> + + - Vinod Gupta <[email protected]> + + - Derek Weitzel <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/CHANGELOG.md new/PyJWT-1.6.3/CHANGELOG.md --- old/PyJWT-1.5.3/CHANGELOG.md 2017-09-05 20:15:26.000000000 +0200 +++ new/PyJWT-1.6.3/CHANGELOG.md 2018-05-19 19:12:59.000000000 +0200 @@ -7,9 +7,47 @@ [Unreleased][unreleased] ------------------------------------------------------------------------- ### Changed + ### Fixed + ### Added +[v1.6.3][1.6.3] +------------------------------------------------------------------------- +### Changed + +- All exceptions inherit from PyJWTError [#340][340] + +### Added + +- Add type hints [#344][344] + +### Docs + +- Added section to usage docs for jwt.get_unverified_header() [#350][350] +- Update legacy instructions for using pycrypto [#337][337] + +[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 + +- Dropped support for python 2.6 and 3.3 [#301][301] +- An invalid signature now raises an `InvalidSignatureError` instead of `DecodeError` [#316][316] + +### Fixed + +- Fix over-eager fallback to stdin [#304][304] + +### Added + +- Audience parameter now supports iterables [#306][306] + [v1.5.3][1.5.3] ------------------------------------------------------------------------- ### Changed @@ -163,6 +201,9 @@ [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 +[1.6.1]: https://github.com/jpadilla/pyjwt/compare/1.6.0...1.6.1 +[1.6.3]: https://github.com/jpadilla/pyjwt/compare/1.6.1...1.6.3 [109]: https://github.com/jpadilla/pyjwt/pull/109 [110]: https://github.com/jpadilla/pyjwt/pull/110 @@ -198,4 +239,14 @@ [271]: https://github.com/jpadilla/pyjwt/pull/271 [277]: https://github.com/jpadilla/pyjwt/pull/277 [281]: https://github.com/jpadilla/pyjwt/pull/281 +[301]: https://github.com/jpadilla/pyjwt/pull/301 +[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 +[336]: https://github.com/jpadilla/pyjwt/pull/336 +[337]: https://github.com/jpadilla/pyjwt/pull/337 +[340]: https://github.com/jpadilla/pyjwt/pull/340 +[344]: https://github.com/jpadilla/pyjwt/pull/344 +[350]: https://github.com/jpadilla/pyjwt/pull/350 [7c1e61d]: https://github.com/jpadilla/pyjwt/commit/7c1e61dde27bafe16e7d1bb6e35199e778962742 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/PKG-INFO new/PyJWT-1.6.3/PKG-INFO --- old/PyJWT-1.5.3/PKG-INFO 2017-09-05 20:21:32.000000000 +0200 +++ new/PyJWT-1.6.3/PKG-INFO 2018-05-19 19:13:35.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: PyJWT -Version: 1.5.3 +Version: 1.6.3 Summary: JSON Web Token implementation in Python Home-page: http://github.com/jpadilla/pyjwt Author: Jose Padilla @@ -25,9 +25,16 @@ .. image:: https://readthedocs.org/projects/pyjwt/badge/?version=latest :target: https://pyjwt.readthedocs.io - A Python implementation of `RFC - 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation - was written by `@progrium <https://github.com/progrium>`_. + A Python implementation of `RFC 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation was written by `@progrium <https://github.com/progrium>`_. + + Sponsor + ------- + + +--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |auth0-logo| | If you want to quickly add secure token-based authentication to Python projects, feel free to check Auth0's Python SDK and free plan at `auth0.com/overview <https://auth0.com/overview?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=pyjwt&utm_content=auth>`_. | + +--------------+-----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + .. |auth0-logo| image:: https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png Installing ---------- @@ -89,9 +96,7 @@ Classifier: Natural Language :: English Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/PyJWT.egg-info/PKG-INFO new/PyJWT-1.6.3/PyJWT.egg-info/PKG-INFO --- old/PyJWT-1.5.3/PyJWT.egg-info/PKG-INFO 2017-09-05 20:21:32.000000000 +0200 +++ new/PyJWT-1.6.3/PyJWT.egg-info/PKG-INFO 2018-05-19 19:13:35.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: PyJWT -Version: 1.5.3 +Version: 1.6.3 Summary: JSON Web Token implementation in Python Home-page: http://github.com/jpadilla/pyjwt Author: Jose Padilla @@ -25,9 +25,16 @@ .. image:: https://readthedocs.org/projects/pyjwt/badge/?version=latest :target: https://pyjwt.readthedocs.io - A Python implementation of `RFC - 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation - was written by `@progrium <https://github.com/progrium>`_. + A Python implementation of `RFC 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation was written by `@progrium <https://github.com/progrium>`_. + + Sponsor + ------- + + +--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | |auth0-logo| | If you want to quickly add secure token-based authentication to Python projects, feel free to check Auth0's Python SDK and free plan at `auth0.com/overview <https://auth0.com/overview?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=pyjwt&utm_content=auth>`_. | + +--------------+-----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + .. |auth0-logo| image:: https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png Installing ---------- @@ -89,9 +96,7 @@ Classifier: Natural Language :: English Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/PyJWT.egg-info/SOURCES.txt new/PyJWT-1.6.3/PyJWT.egg-info/SOURCES.txt --- old/PyJWT-1.5.3/PyJWT.egg-info/SOURCES.txt 2017-09-05 20:21:32.000000000 +0200 +++ new/PyJWT-1.6.3/PyJWT.egg-info/SOURCES.txt 2018-05-19 19:13:35.000000000 +0200 @@ -19,15 +19,14 @@ jwt/api_jwt.py jwt/compat.py jwt/exceptions.py +jwt/help.py jwt/utils.py jwt/contrib/__init__.py jwt/contrib/algorithms/__init__.py jwt/contrib/algorithms/py_ecdsa.py jwt/contrib/algorithms/pycrypto.py tests/__init__.py -tests/__init__.pyc tests/compat.py -tests/compat.pyc tests/test_algorithms.py tests/test_api_jws.py tests/test_api_jwt.py @@ -37,21 +36,9 @@ tests/test_jwt.py tests/test_utils.py tests/utils.py -tests/utils.pyc -tests/__pycache__/test_algorithms.cpython-27-PYTEST.pyc -tests/__pycache__/test_api_jws.cpython-27-PYTEST.pyc -tests/__pycache__/test_api_jwt.cpython-27-PYTEST.pyc -tests/__pycache__/test_cli.cpython-27-PYTEST.pyc -tests/__pycache__/test_compat.cpython-27-PYTEST.pyc -tests/__pycache__/test_exceptions.cpython-27-PYTEST.pyc -tests/__pycache__/test_jwt.cpython-27-PYTEST.pyc -tests/__pycache__/test_utils.cpython-27-PYTEST.pyc tests/contrib/__init__.py -tests/contrib/__init__.pyc tests/contrib/test_algorithms.py -tests/contrib/__pycache__/test_algorithms.cpython-27-PYTEST.pyc tests/keys/__init__.py -tests/keys/__init__.pyc tests/keys/jwk_ec_key.json tests/keys/jwk_ec_pub.json tests/keys/jwk_hmac.json diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/README.rst new/PyJWT-1.6.3/README.rst --- old/PyJWT-1.5.3/README.rst 2017-05-18 04:08:12.000000000 +0200 +++ new/PyJWT-1.6.3/README.rst 2018-03-03 15:45:20.000000000 +0100 @@ -16,9 +16,16 @@ .. image:: https://readthedocs.org/projects/pyjwt/badge/?version=latest :target: https://pyjwt.readthedocs.io -A Python implementation of `RFC -7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation -was written by `@progrium <https://github.com/progrium>`_. +A Python implementation of `RFC 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation was written by `@progrium <https://github.com/progrium>`_. + +Sponsor +------- + ++--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| |auth0-logo| | If you want to quickly add secure token-based authentication to Python projects, feel free to check Auth0's Python SDK and free plan at `auth0.com/overview <https://auth0.com/overview?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=pyjwt&utm_content=auth>`_. | ++--------------+-----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. |auth0-logo| image:: https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png Installing ---------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/__init__.py new/PyJWT-1.6.3/jwt/__init__.py --- old/PyJWT-1.5.3/jwt/__init__.py 2017-09-05 20:15:42.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/__init__.py 2018-05-19 19:13:02.000000000 +0200 @@ -10,10 +10,10 @@ __title__ = 'pyjwt' -__version__ = '1.5.3' +__version__ = '1.6.3' __author__ = 'José Padilla' __license__ = 'MIT' -__copyright__ = 'Copyright 2015 José Padilla' +__copyright__ = 'Copyright 2015-2018 José Padilla' from .api_jwt import ( @@ -25,5 +25,7 @@ InvalidTokenError, DecodeError, InvalidAlgorithmError, InvalidAudienceError, ExpiredSignatureError, ImmatureSignatureError, InvalidIssuedAtError, InvalidIssuerError, ExpiredSignature, - InvalidAudience, InvalidIssuer, MissingRequiredClaimError + InvalidAudience, InvalidIssuer, MissingRequiredClaimError, + InvalidSignatureError, + PyJWTError, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/__main__.py new/PyJWT-1.6.3/jwt/__main__.py --- old/PyJWT-1.5.3/jwt/__main__.py 2017-06-21 21:27:06.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/__main__.py 2018-03-03 15:45:20.000000000 +0100 @@ -54,10 +54,13 @@ def decode_payload(args): try: - if sys.stdin.isatty(): - token = sys.stdin.read() - else: + if args.token: token = args.token + else: + if sys.stdin.isatty(): + token = sys.stdin.readline().strip() + else: + raise IOError('Cannot read from stdin: terminal not a TTY') token = token.encode('utf-8') data = decode(token, key=args.key, verify=args.verify) @@ -133,7 +136,10 @@ # Decode subcommand decode_parser = subparsers.add_parser('decode', help='use to decode a supplied JSON web token') - decode_parser.add_argument('token', help='JSON web token to decode.') + decode_parser.add_argument( + 'token', + help='JSON web token to decode.', + nargs='?') decode_parser.add_argument( '-n', '--no-verify', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/api_jws.py new/PyJWT-1.6.3/jwt/api_jws.py --- old/PyJWT-1.5.3/jwt/api_jws.py 2017-09-05 20:14:00.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/api_jws.py 2018-05-19 14:42:58.000000000 +0200 @@ -1,14 +1,21 @@ import binascii import json import warnings - from collections import Mapping +try: + # import required by mypy to perform type checking, not used for normal execution + from typing import Callable, Dict, List, Optional, Union # NOQA +except ImportError: + pass from .algorithms import ( Algorithm, get_default_algorithms, has_crypto, requires_cryptography # NOQA ) from .compat import binary_type, string_types, text_type -from .exceptions import DecodeError, InvalidAlgorithmError, InvalidTokenError +from .exceptions import ( + DecodeError, InvalidAlgorithmError, InvalidSignatureError, + InvalidTokenError +) from .utils import base64url_decode, base64url_encode, force_bytes, merge_dict @@ -67,8 +74,13 @@ """ return list(self._valid_algs) - def encode(self, payload, key, algorithm='HS256', headers=None, - json_encoder=None): + def encode(self, + payload, # type: Union[Dict, bytes] + key, # type: str + algorithm='HS256', # type: str + headers=None, # type: Optional[Dict] + json_encoder=None # type: Optional[Callable] + ): segments = [] if algorithm is None: @@ -115,7 +127,12 @@ return b'.'.join(segments) - def decode(self, jws, key='', verify=True, algorithms=None, options=None, + def decode(self, + token, # type: str + key='', # type: str + verify=True, # type: bool + algorithms=None, # type: List[str] + options=None, # type: Dict **kwargs): merged_options = merge_dict(self.options, options) @@ -129,7 +146,7 @@ DeprecationWarning ) - payload, signing_input, header, signature = self._load(jws) + payload, signing_input, header, signature = self._load(token) if not verify: warnings.warn('The verify parameter is deprecated. ' @@ -204,7 +221,7 @@ key = alg_obj.prepare_key(key) if not alg_obj.verify(signing_input, key, signature): - raise DecodeError('Signature verification failed') + raise InvalidSignatureError('Signature verification failed') except KeyError: raise InvalidAlgorithmError('Algorithm not supported') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/api_jwt.py new/PyJWT-1.6.3/jwt/api_jwt.py --- old/PyJWT-1.5.3/jwt/api_jwt.py 2017-09-05 20:14:00.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/api_jwt.py 2018-05-19 14:42:58.000000000 +0200 @@ -1,13 +1,17 @@ import json import warnings - from calendar import timegm -from collections import Mapping +from collections import Iterable, Mapping from datetime import datetime, timedelta +try: + # import required by mypy to perform type checking, not used for normal execution + from typing import Callable, Dict, List, Optional, Union # NOQA +except ImportError: + pass from .api_jws import PyJWS from .algorithms import Algorithm, get_default_algorithms # NOQA -from .compat import string_types, timedelta_total_seconds +from .compat import string_types from .exceptions import ( DecodeError, ExpiredSignatureError, ImmatureSignatureError, InvalidAudienceError, InvalidIssuedAtError, @@ -21,6 +25,7 @@ @staticmethod def _get_default_options(): + # type: () -> Dict[str, bool] return { 'verify_signature': True, 'verify_exp': True, @@ -33,8 +38,13 @@ 'require_nbf': False } - def encode(self, payload, key, algorithm='HS256', headers=None, - json_encoder=None): + def encode(self, + payload, # type: Union[Dict, bytes] + key, # type: str + algorithm='HS256', # type: str + headers=None, # type: Optional[Dict] + json_encoder=None # type: Optional[Callable] + ): # Check that we get a mapping if not isinstance(payload, Mapping): raise TypeError('Expecting a mapping object, as JWT only supports ' @@ -44,7 +54,7 @@ for time_claim in ['exp', 'iat', 'nbf']: # Convert datetime to a intDate value in known time-format claims if isinstance(payload.get(time_claim), datetime): - payload[time_claim] = timegm(payload[time_claim].utctimetuple()) + payload[time_claim] = timegm(payload[time_claim].utctimetuple()) # type: ignore json_payload = json.dumps( payload, @@ -56,7 +66,12 @@ json_payload, key, algorithm, headers, json_encoder ) - def decode(self, jwt, key='', verify=True, algorithms=None, options=None, + def decode(self, + token, # type: str + key='', # type: str + verify=True, # type: bool + algorithms=None, # type: List[str] + options=None, # type: Dict **kwargs): if verify and not algorithms: @@ -67,7 +82,7 @@ DeprecationWarning ) - payload, signing_input, header, signature = self._load(jwt) + payload, _, _, _ = self._load(token) if options is None: options = {'verify_signature': verify} @@ -75,7 +90,7 @@ options.setdefault('verify_signature', verify) decoded = super(PyJWT, self).decode( - jwt, key=key, algorithms=algorithms, options=options, **kwargs + token, key=key, algorithms=algorithms, options=options, **kwargs ) try: @@ -101,10 +116,10 @@ DeprecationWarning) if isinstance(leeway, timedelta): - leeway = timedelta_total_seconds(leeway) + leeway = leeway.total_seconds() - if not isinstance(audience, (string_types, type(None))): - raise TypeError('audience must be a string or None') + if not isinstance(audience, (string_types, type(None), Iterable)): + raise TypeError('audience must be a string, iterable, or None') self._validate_required_claims(payload, options) @@ -169,6 +184,11 @@ # 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): @@ -177,7 +197,11 @@ raise InvalidAudienceError('Invalid claim format in token') if any(not isinstance(c, string_types) for c in audience_claims): raise InvalidAudienceError('Invalid claim format in token') - if audience not in audience_claims: + + if isinstance(audience, string_types): + audience = [audience] + + if not any(aud in audience_claims for aud in audience): raise InvalidAudienceError('Invalid audience') def _validate_iss(self, payload, issuer): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/compat.py new/PyJWT-1.6.3/jwt/compat.py --- old/PyJWT-1.5.3/jwt/compat.py 2017-03-08 17:28:19.000000000 +0100 +++ new/PyJWT-1.6.3/jwt/compat.py 2018-03-03 15:45:20.000000000 +0100 @@ -21,19 +21,6 @@ string_types = (text_type, binary_type) -def timedelta_total_seconds(delta): - try: - delta.total_seconds - except AttributeError: - # On Python 2.6, timedelta instances do not have - # a .total_seconds() method. - total_seconds = delta.days * 24 * 60 * 60 + delta.seconds - else: - total_seconds = delta.total_seconds() - - return total_seconds - - try: constant_time_compare = hmac.compare_digest except AttributeError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/contrib/algorithms/pycrypto.py new/PyJWT-1.6.3/jwt/contrib/algorithms/pycrypto.py --- old/PyJWT-1.5.3/jwt/contrib/algorithms/pycrypto.py 2015-05-30 16:21:11.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/contrib/algorithms/pycrypto.py 2018-03-03 15:45:20.000000000 +0100 @@ -1,7 +1,6 @@ import Crypto.Hash.SHA256 import Crypto.Hash.SHA384 import Crypto.Hash.SHA512 - from Crypto.PublicKey import RSA from Crypto.Signature import PKCS1_v1_5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/exceptions.py new/PyJWT-1.6.3/jwt/exceptions.py --- old/PyJWT-1.5.3/jwt/exceptions.py 2015-07-17 03:17:27.000000000 +0200 +++ new/PyJWT-1.6.3/jwt/exceptions.py 2018-05-19 14:42:58.000000000 +0200 @@ -1,4 +1,11 @@ -class InvalidTokenError(Exception): +class PyJWTError(Exception): + """ + Base class for all exceptions + """ + pass + + +class InvalidTokenError(PyJWTError): pass @@ -6,6 +13,10 @@ pass +class InvalidSignatureError(DecodeError): + pass + + class ExpiredSignatureError(InvalidTokenError): pass @@ -26,7 +37,7 @@ pass -class InvalidKeyError(Exception): +class InvalidKeyError(PyJWTError): pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/jwt/help.py new/PyJWT-1.6.3/jwt/help.py --- old/PyJWT-1.5.3/jwt/help.py 1970-01-01 01:00:00.000000000 +0100 +++ new/PyJWT-1.6.3/jwt/help.py 2018-05-19 15:37:15.000000000 +0200 @@ -0,0 +1,61 @@ +from __future__ import print_function + +import json +import platform +import sys + +from . import __version__ as pyjwt_version + +try: + import cryptography +except ImportError: + cryptography = None + +try: + import ecdsa +except ImportError: + ecdsa = None + + +def info(): + """ + Generate information for a bug report. + Based on the requests package help utility module. + """ + try: + platform_info = {"system": platform.system(), "release": platform.release()} + except IOError: + platform_info = {"system": "Unknown", "release": "Unknown"} + + implementation = platform.python_implementation() + + if implementation == "CPython": + implementation_version = platform.python_version() + elif implementation == "PyPy": + implementation_version = "%s.%s.%s" % ( + sys.pypy_version_info.major, + sys.pypy_version_info.minor, + sys.pypy_version_info.micro, + ) + if sys.pypy_version_info.releaselevel != "final": + implementation_version = "".join( + [implementation_version, sys.pypy_version_info.releaselevel] + ) + else: + implementation_version = "Unknown" + + return { + "platform": platform_info, + "implementation": {"name": implementation, "version": implementation_version}, + "cryptography": {"version": getattr(cryptography, "__version__", "")}, + "pyjwt": {"version": pyjwt_version}, + } + + +def main(): + """Pretty-print the bug information as JSON.""" + print(json.dumps(info(), sort_keys=True, indent=2)) + + +if __name__ == "__main__": + main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/setup.py new/PyJWT-1.6.3/setup.py --- old/PyJWT-1.5.3/setup.py 2017-09-05 20:19:52.000000000 +0200 +++ new/PyJWT-1.6.3/setup.py 2018-03-03 15:45:20.000000000 +0100 @@ -60,9 +60,7 @@ 'Natural Language :: English', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', Binary files old/PyJWT-1.5.3/tests/__init__.pyc and new/PyJWT-1.6.3/tests/__init__.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_algorithms.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_algorithms.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_api_jws.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_api_jws.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_api_jwt.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_api_jwt.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_cli.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_cli.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_compat.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_compat.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_exceptions.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_exceptions.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_jwt.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_jwt.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/__pycache__/test_utils.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/__pycache__/test_utils.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/compat.pyc and new/PyJWT-1.6.3/tests/compat.pyc differ Binary files old/PyJWT-1.5.3/tests/contrib/__init__.pyc and new/PyJWT-1.6.3/tests/contrib/__init__.pyc differ Binary files old/PyJWT-1.5.3/tests/contrib/__pycache__/test_algorithms.cpython-27-PYTEST.pyc and new/PyJWT-1.6.3/tests/contrib/__pycache__/test_algorithms.cpython-27-PYTEST.pyc differ Binary files old/PyJWT-1.5.3/tests/keys/__init__.pyc and new/PyJWT-1.6.3/tests/keys/__init__.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/tests/test_api_jws.py new/PyJWT-1.6.3/tests/test_api_jws.py --- old/PyJWT-1.5.3/tests/test_api_jws.py 2017-09-05 20:14:00.000000000 +0200 +++ new/PyJWT-1.6.3/tests/test_api_jws.py 2018-03-03 15:45:20.000000000 +0100 @@ -1,12 +1,12 @@ import json - from decimal import Decimal from jwt.algorithms import Algorithm from jwt.api_jws import PyJWS from jwt.exceptions import ( - DecodeError, InvalidAlgorithmError, InvalidTokenError + DecodeError, InvalidAlgorithmError, InvalidSignatureError, + InvalidTokenError ) from jwt.utils import base64url_decode, force_bytes, force_unicode @@ -179,8 +179,14 @@ bad_secret = 'bar' jws_message = jws.encode(payload, right_secret) - with pytest.raises(DecodeError): + with pytest.raises(DecodeError) as excinfo: + # Backward compat for ticket #315 + jws.decode(jws_message, bad_secret) + assert 'Signature verification failed' == str(excinfo.value) + + with pytest.raises(InvalidSignatureError) as excinfo: jws.decode(jws_message, bad_secret) + assert 'Signature verification failed' == str(excinfo.value) def test_decodes_valid_jws(self, jws, payload): example_secret = 'secret' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/tests/test_api_jwt.py new/PyJWT-1.6.3/tests/test_api_jwt.py --- old/PyJWT-1.5.3/tests/test_api_jwt.py 2017-09-05 20:14:00.000000000 +0200 +++ new/PyJWT-1.6.3/tests/test_api_jwt.py 2018-03-18 14:35:35.000000000 +0100 @@ -1,7 +1,6 @@ import json import time - from calendar import timegm from datetime import datetime, timedelta from decimal import Decimal @@ -92,7 +91,7 @@ jwt.decode(example_jwt, secret, audience=1) exception = context.value - assert str(exception) == 'audience must be a string or None' + assert str(exception) == 'audience must be a string, iterable, or None' def test_decode_with_nonlist_aud_claim_throws_exception(self, jwt): secret = 'secret' @@ -281,6 +280,32 @@ token = jwt.encode(payload, 'secret') jwt.decode(token, 'secret', audience='urn:me') + def test_check_audience_list_when_valid(self, jwt): + payload = { + 'some': 'payload', + 'aud': 'urn:me' + } + 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', + 'aud': 'urn:me' + } + token = jwt.encode(payload, 'secret') + with pytest.raises(InvalidAudienceError): + jwt.decode(token, 'secret', audience=['urn:you', 'urn:him']) + def test_check_audience_in_array_when_valid(self, jwt): payload = { 'some': 'payload', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/tests/test_cli.py new/PyJWT-1.6.3/tests/test_cli.py --- old/PyJWT-1.5.3/tests/test_cli.py 2017-06-21 21:27:06.000000000 +0200 +++ new/PyJWT-1.6.3/tests/test_cli.py 2018-03-03 15:45:20.000000000 +0100 @@ -57,6 +57,37 @@ assert 'There was an error decoding the token' in str(excinfo.value) + def test_decode_payload_terminal_tty(self, monkeypatch): + encode_args = [ + '--key=secret-key', + 'encode', + 'name=hello-world', + ] + parser = build_argparser() + parsed_encode_args = parser.parse_args(encode_args) + token = encode_payload(parsed_encode_args) + + decode_args = ['--key=secret-key', 'decode'] + parsed_decode_args = parser.parse_args(decode_args) + + monkeypatch.setattr(sys.stdin, 'isatty', lambda: True) + monkeypatch.setattr(sys.stdin, 'readline', lambda: token) + + actual = json.loads(decode_payload(parsed_decode_args)) + assert actual['name'] == 'hello-world' + + def test_decode_payload_raises_terminal_not_a_tty(self, monkeypatch): + decode_args = ['--key', '1234', 'decode'] + parser = build_argparser() + args = parser.parse_args(decode_args) + + monkeypatch.setattr(sys.stdin, 'isatty', lambda: False) + + with pytest.raises(IOError) as excinfo: + decode_payload(args) + assert 'Cannot read from stdin: terminal not a TTY' \ + in str(excinfo.value) + @pytest.mark.parametrize('key,name,job,exp,verify', [ ('1234', 'Vader', 'Sith', None, None), ('4567', 'Anakin', 'Jedi', '+1', None), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/tests/utils.py new/PyJWT-1.6.3/tests/utils.py --- old/PyJWT-1.5.3/tests/utils.py 2017-03-08 17:28:19.000000000 +0100 +++ new/PyJWT-1.6.3/tests/utils.py 2018-03-03 15:45:20.000000000 +0100 @@ -1,6 +1,5 @@ import os import struct - from calendar import timegm from datetime import datetime Binary files old/PyJWT-1.5.3/tests/utils.pyc and new/PyJWT-1.6.3/tests/utils.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyJWT-1.5.3/tox.ini new/PyJWT-1.6.3/tox.ini --- old/PyJWT-1.5.3/tox.ini 2017-05-18 04:08:12.000000000 +0200 +++ new/PyJWT-1.6.3/tox.ini 2018-05-19 14:42:58.000000000 +0200 @@ -1,5 +1,5 @@ [tox] -envlist = py{26,27,33,34,35,36}-crypto, py{27,35,36}-contrib_crypto, py{27,35,36}-nocrypto, flake8 +envlist = py{27,34,35,36}-crypto, py{27,35,36}-contrib_crypto, py{27,35,36}-nocrypto, flake8 [testenv] commands = @@ -15,4 +15,4 @@ deps = flake8 flake8-import-order - pep8-naming + pep8-naming \ No newline at end of file
