diff options
author | Mark Adams <mark@markadams.me> | 2015-03-17 14:55:22 -0500 |
---|---|---|
committer | Mark Adams <madams@atlassian.com> | 2015-03-17 14:56:52 -0500 |
commit | 3e59fe6c9e88d212180dfec61b36d58858af0367 (patch) | |
tree | f1c18b7a756f958ecb13894aa50638d7fb28231f /jwt/algorithms.py | |
parent | fd3a489e975afe490442c6b12f089263557bd341 (diff) | |
download | pyjwt-3e59fe6c9e88d212180dfec61b36d58858af0367.tar.gz |
Added a check to raise an error if alg = 'none' and a key is specified. (Fixes #106)
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r-- | jwt/algorithms.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py index 6ba8c12..83d7d12 100644 --- a/jwt/algorithms.py +++ b/jwt/algorithms.py @@ -2,7 +2,7 @@ import hashlib import hmac from .compat import constant_time_compare, string_types, text_type -from .exceptions import InvalidAlgorithmError +from .exceptions import InvalidKeyError try: from cryptography.hazmat.primitives import interfaces, hashes @@ -69,6 +69,9 @@ class NoneAlgorithm(Algorithm): operations are required. """ def prepare_key(self, key): + if key is not None: + raise InvalidKeyError('When alg = "none", key value must be None.') + return None def sign(self, msg, key): |