summaryrefslogtreecommitdiff
path: root/jwt/api_jws.py
diff options
context:
space:
mode:
authorLandon GB <landogbland@gmail.com>2016-11-30 09:33:46 -0700
committerLandon GB <landogbland@gmail.com>2016-11-30 09:33:46 -0700
commit0550fa347ed29e2ffcd8f26a3adcf0ddcae6fdc3 (patch)
treec3b7b81d13b8f6b7bdaefe0788ba904ff99b3454 /jwt/api_jws.py
parent8520c8f0e0c9ea13df785e8143ee193f088c008a (diff)
downloadpyjwt-0550fa347ed29e2ffcd8f26a3adcf0ddcae6fdc3.tar.gz
Changes per code review
Diffstat (limited to 'jwt/api_jws.py')
-rw-r--r--jwt/api_jws.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index df54e3f..66b6a67 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -5,7 +5,7 @@ import warnings
from collections import Mapping
from .algorithms import (
- Algorithm, get_crypto_algorithms, get_default_algorithms, has_crypto # NOQA
+ Algorithm, get_default_algorithms, has_crypto, requires_cryptography # NOQA
)
from .compat import binary_type, string_types, text_type
from .exceptions import DecodeError, InvalidAlgorithmError, InvalidTokenError
@@ -103,9 +103,11 @@ class PyJWS(object):
signature = alg_obj.sign(signing_input, key)
except KeyError:
- if not has_crypto and algorithm in get_crypto_algorithms():
- raise NotImplementedError('"cryptography" package must be '
- 'installed to use this algorithm')
+ if not has_crypto and algorithm in requires_cryptography:
+ raise NotImplementedError(
+ "Algorithm '%s' could not be found. Do you have cryptography "
+ "installed?" % algorithm
+ )
else:
raise NotImplementedError('Algorithm not supported')