diff options
author | José Padilla <jpadilla@webapplicate.com> | 2014-05-14 18:49:51 -0400 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2014-05-14 18:49:51 -0400 |
commit | cf7eacccb433eb1600f5e2cf1199241f0725eccc (patch) | |
tree | b2d79044f03c547d10f6f7cf3c69f18031578994 | |
parent | 0ee3ee579bd2a008d3b3a137e776a25661f2365c (diff) | |
parent | e73045dbddbd5e1650520a8656efd20ff6dda8be (diff) | |
download | pyjwt-cf7eacccb433eb1600f5e2cf1199241f0725eccc.tar.gz |
Merge pull request #35 from tgs/algorithm-case-insensitive
Allow algorithm names to be upper- or lower-case
-rw-r--r-- | jwt/__init__.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/jwt/__init__.py b/jwt/__init__.py index fd38bd1..a68055d 100644 --- a/jwt/__init__.py +++ b/jwt/__init__.py @@ -220,13 +220,14 @@ def load(jwt): def verify_signature(payload, signing_input, header, signature, key='', verify_expiration=True, leeway=0): try: - key = prepare_key_methods[header['alg']](key) - if header['alg'].startswith('HS'): - expected = verify_methods[header['alg']](signing_input, key) + algorithm = header['alg'].upper() + key = prepare_key_methods[algorithm](key) + if algorithm.startswith('HS'): + expected = verify_methods[algorithm](signing_input, key) if not constant_time_compare(signature, expected): raise DecodeError("Signature verification failed") else: - if not verify_methods[header['alg']](signing_input, key, signature): + if not verify_methods[algorithm](signing_input, key, signature): raise DecodeError("Signature verification failed") except KeyError: raise DecodeError("Algorithm not supported") |