Skip to content

Commit d1b3e52

Browse files
author
Gasper Zejn
committed
Merge remote-tracking branch 'mpdavis/master'
2 parents 364fb0b + 28cc671 commit d1b3e52

File tree

8 files changed

+47
-34
lines changed

8 files changed

+47
-34
lines changed

.travis.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
sudo: false
21
# Travis infra requires pinning dist:precise, at least as of 2017-09-01
32
# detail: https://blog.travis-ci.com/2017-06-21-trusty-updates-2017-Q2-launch
43
dist: precise
54
language: python
65
python:
7-
- "2.6"
86
- "2.7"
9-
- "3.3"
107
- "3.4"
118
- "3.5"
129
- "3.6"
1310
- "pypy-5.3.1"
1411
install:
15-
- pip install -U tox codecov tox-travis
12+
- pip install -U setuptools && pip install -U tox codecov tox-travis
1613
script:
1714
- tox
1815
after_success:
19-
- codecov
16+
- codecov
17+
# matrix:
18+
# include:
19+
# - python: 3.6
20+
# env:
21+
# - TOX_ENV=flake8
22+
# script: tox -e $TOX_ENV

README.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ expected that most applications will only use a small set of algorithms
1616
to meet their needs.
1717

1818

19-
Principles
20-
----------
21-
22-
This is a JOSE implementation that is fully compatible with Google App Engine
23-
which requires the use of the PyCrypto library.
24-
25-
2619
Installation
2720
------------
2821

@@ -31,6 +24,20 @@ Installation
3124
$ pip install python-jose
3225

3326

27+
Custom Backends
28+
---------------
29+
30+
As of 2.0.0, python-jose uses pycryptodome by default for RSA signing and verification. If
31+
necessary, other RSA backends are supported. Both pycrpyto and crytography are options.
32+
33+
In order to use a custom backend, install python-jose with the appropriate extra.
34+
35+
::
36+
37+
$ pip install python-jose[pycrypto]
38+
$ pip install python-jose[crytography]
39+
40+
3441
Usage
3542
-----
3643

jose/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
__version__ = "1.4.0"
2+
__version__ = "2.0.2"
33
__author__ = 'Michael Davis'
44
__license__ = 'MIT'
55
__copyright__ = 'Copyright 2016 Michael Davis'

jose/backends/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from jose.backends.pycrypto_backend import RSAKey
44
except ImportError:
55
from jose.backends.cryptography_backend import CryptographyRSAKey as RSAKey
6-
6+
77
try:
88
from jose.backends.cryptography_backend import CryptographyECKey as ECKey
99
except ImportError:

jose/backends/pycrypto_backend.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
from jose.exceptions import JWKError
1515
from jose.utils import base64url_decode
1616

17-
# PyCryptodome's RSA module doesn't have PyCrypto's _RSAobj class
18-
# Instead it has a class named RsaKey, which serves the same purpose.
19-
if hasattr(RSA, '_RSAobj'):
20-
_RSAKey = RSA._RSAobj
21-
else:
17+
18+
# We default to using PyCryptodome, however, if PyCrypto is installed, it is
19+
# used instead. This is so that environments that require the use of PyCrypto
20+
# are still supported.
21+
if hasattr(RSA, 'RsaKey'):
2222
_RSAKey = RSA.RsaKey
23+
else:
24+
_RSAKey = RSA._RSAobj
25+
2326

2427

2528
class RSAKey(Key):

jose/jwt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def decode(token, key, algorithms=None, options=None, audience=None,
102102
103103
Raises:
104104
JWTError: If the signature is invalid in any way.
105+
ExpiredSignatureError: If the signature has expired.
106+
JWTClaimsError: If any claim is invalid in any way.
105107
106108
Examples:
107109

setup.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import sys
55
import jose
66

7-
import platform
8-
97
from setuptools import setup
108

119

@@ -24,17 +22,10 @@ def get_packages(package):
2422
]
2523

2624

27-
def get_install_requires():
28-
if sys.platform == "win32" or platform.python_implementation() == 'PyPy':
29-
crypto_lib = 'pycryptodome >=3.3.1, <3.4.0'
30-
else:
31-
crypto_lib = 'pycrypto >=2.6.0, <2.7.0'
32-
return [
33-
crypto_lib,
34-
'six <2.0',
35-
'ecdsa <1.0',
36-
'future <1.0',
37-
]
25+
extras_require = {
26+
'cryptography': ['cryptography'],
27+
'pycrypto': ['pycrypto >=2.6.0, <2.7.0'],
28+
}
3829

3930

4031
setup(
@@ -63,5 +54,6 @@ def get_install_requires():
6354
'Programming Language :: Python :: Implementation :: PyPy',
6455
'Topic :: Utilities',
6556
],
66-
install_requires=get_install_requires()
57+
extras_require=extras_require,
58+
install_requires=['six <2.0', 'ecdsa <1.0', 'future <1.0', 'pycryptodome >=3.3.1, <4.0.0']
6759
)

tox.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tox]
2-
envlist = py{26,27,33,34,py}
2+
envlist = py{27,34,35,36,py},flake8
3+
skip_missing_interpreters = True
34

45
[testenv]
56
commands =
@@ -13,3 +14,8 @@ deps =
1314
pytest-runner
1415
cryptography
1516

17+
; [testenv:flake8]
18+
; commands = flake8 jose
19+
; skip_install= True
20+
; deps =
21+
; flake8

0 commit comments

Comments
 (0)