[Python-modules-commits] [pyjwt] 02/03: Import pyjwt_1.4.2.orig.tar.gz
Daniele Tricoli
eriol-guest at moszumanska.debian.org
Thu Sep 8 23:17:57 UTC 2016
This is an automated email from the git hooks/post-receive script.
eriol-guest pushed a commit to branch master
in repository pyjwt.
commit e684bf651d7184285933061dcce292b7695428a4
Author: Daniele Tricoli <eriol at mornie.org>
Date: Fri Sep 9 01:09:48 2016 +0200
Import pyjwt_1.4.2.orig.tar.gz
---
CHANGELOG.md | 19 +++++++++++++++++++
PKG-INFO | 2 +-
PyJWT.egg-info/PKG-INFO | 2 +-
jwt/__init__.py | 2 +-
jwt/algorithms.py | 14 +++++++-------
jwt/compat.py | 8 ++++++--
setup.cfg | 4 +++-
tests/test_algorithms.py | 14 ++++++++++++++
8 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 573eabd..de4b14d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+[v1.4.2][1.4.2]
+-------------------------------------------------------------------------
+### Fixed
+- A PEM-formatted key encoded as bytes could cause a `TypeError` to be raised [#213][213]
+
+[v1.4.1][1.4.1]
+-------------------------------------------------------------------------
+### Fixed
+- Newer versions of Pytest could not detect warnings properly [#182][182]
+- Non-string 'kid' value now raises `InvalidTokenError` [#174][174]
+- `jwt.decode(None)` now gracefully fails with `InvalidTokenError` [#183][183]
+
[v1.4][1.4.0]
-------------------------------------------------------------------------
### Fixed
@@ -86,6 +98,9 @@ rarely used. Users affected by this should upgrade to 3.3+.
[1.2.0]: https://github.com/jpadilla/pyjwt/compare/1.1.0...1.2.0
[1.3.0]: https://github.com/jpadilla/pyjwt/compare/1.2.0...1.3.0
[1.4.0]: https://github.com/jpadilla/pyjwt/compare/1.3.0...1.4.0
+[1.4.1]: https://github.com/jpadilla/pyjwt/compare/1.4.0...1.4.1
+[1.4.2]: https://github.com/jpadilla/pyjwt/compare/1.4.1...1.4.2
+
[109]: https://github.com/jpadilla/pyjwt/pull/109
@@ -102,3 +117,7 @@ rarely used. Users affected by this should upgrade to 3.3+.
[141]: https://github.com/jpadilla/pyjwt/pull/141
[158]: https://github.com/jpadilla/pyjwt/pull/158
[163]: https://github.com/jpadilla/pyjwt/pull/163
+[174]: https://github.com/jpadilla/pyjwt/pull/174
+[182]: https://github.com/jpadilla/pyjwt/pull/182
+[183]: https://github.com/jpadilla/pyjwt/pull/183
+[213]: https://github.com/jpadilla/pyjwt/pull/214
diff --git a/PKG-INFO b/PKG-INFO
index 91af37c..75d18a9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: PyJWT
-Version: 1.4.1
+Version: 1.4.2
Summary: JSON Web Token implementation in Python
Home-page: http://github.com/jpadilla/pyjwt
Author: José Padilla
diff --git a/PyJWT.egg-info/PKG-INFO b/PyJWT.egg-info/PKG-INFO
index 91af37c..75d18a9 100644
--- a/PyJWT.egg-info/PKG-INFO
+++ b/PyJWT.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: PyJWT
-Version: 1.4.1
+Version: 1.4.2
Summary: JSON Web Token implementation in Python
Home-page: http://github.com/jpadilla/pyjwt
Author: José Padilla
diff --git a/jwt/__init__.py b/jwt/__init__.py
index d70cdf0..64b2f97 100644
--- a/jwt/__init__.py
+++ b/jwt/__init__.py
@@ -10,7 +10,7 @@ http://self-issued.info/docs/draft-jones-json-web-token-01.html
__title__ = 'pyjwt'
-__version__ = '1.4.1'
+__version__ = '1.4.2'
__author__ = 'José Padilla'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015 José Padilla'
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index 9c1a7e8..51e8f16 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -1,7 +1,7 @@
import hashlib
import hmac
-from .compat import constant_time_compare, string_types, text_type
+from .compat import binary_type, constant_time_compare, is_string_type
from .exceptions import InvalidKeyError
from .utils import der_to_raw_signature, raw_to_der_signature
@@ -112,10 +112,10 @@ class HMACAlgorithm(Algorithm):
self.hash_alg = hash_alg
def prepare_key(self, key):
- if not isinstance(key, string_types) and not isinstance(key, bytes):
+ if not is_string_type(key):
raise TypeError('Expecting a string- or bytes-formatted key.')
- if isinstance(key, text_type):
+ if not isinstance(key, binary_type):
key = key.encode('utf-8')
invalid_strings = [
@@ -156,8 +156,8 @@ if has_crypto:
isinstance(key, RSAPublicKey):
return key
- if isinstance(key, string_types):
- if isinstance(key, text_type):
+ if is_string_type(key):
+ if not isinstance(key, binary_type):
key = key.encode('utf-8')
try:
@@ -213,8 +213,8 @@ if has_crypto:
isinstance(key, EllipticCurvePublicKey):
return key
- if isinstance(key, string_types):
- if isinstance(key, text_type):
+ if is_string_type(key):
+ if not isinstance(key, binary_type):
key = key.encode('utf-8')
# Attempt to load key. We don't know if it's
diff --git a/jwt/compat.py b/jwt/compat.py
index 8f6bfed..dafd0c7 100644
--- a/jwt/compat.py
+++ b/jwt/compat.py
@@ -11,14 +11,18 @@ PY3 = sys.version_info[0] == 3
if PY3:
- string_types = str,
text_type = str
binary_type = bytes
else:
- string_types = basestring,
text_type = unicode
binary_type = str
+string_types = (text_type, binary_type)
+
+
+def is_string_type(val):
+ return any([isinstance(val, typ) for typ in string_types])
+
def timedelta_total_seconds(delta):
try:
diff --git a/setup.cfg b/setup.cfg
index 5b0a9fe..c796d44 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,8 @@
[flake8]
max-line-length = 119
-exclude = docs/
+exclude =
+ docs/,
+ .tox/
[wheel]
universal = 1
diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py
index 45bb6d1..e3cf1d0 100644
--- a/tests/test_algorithms.py
+++ b/tests/test_algorithms.py
@@ -92,6 +92,13 @@ class TestAlgorithms:
algo.prepare_key(pem_key.read())
@pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
+ def test_rsa_should_accept_pem_private_key_bytes(self):
+ algo = RSAAlgorithm(RSAAlgorithm.SHA256)
+
+ with open(key_path('testkey_rsa'), 'rb') as pem_key:
+ algo.prepare_key(pem_key.read())
+
+ @pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
def test_rsa_should_accept_unicode_key(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)
@@ -142,6 +149,13 @@ class TestAlgorithms:
algo.prepare_key(ensure_unicode(ec_key.read()))
@pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
+ def test_ec_should_accept_pem_private_key_bytes(self):
+ algo = ECAlgorithm(ECAlgorithm.SHA256)
+
+ with open(key_path('testkey_ec'), 'rb') as ec_key:
+ algo.prepare_key(ec_key.read())
+
+ @pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
def test_ec_verify_should_return_false_if_signature_invalid(self):
algo = ECAlgorithm(ECAlgorithm.SHA256)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyjwt.git
More information about the Python-modules-commits
mailing list