Skip to content

Commit eb7c5fe

Browse files
authored
Merge pull request #185 from MatTerra/master
Made json.loads process numbers as strings; closes #45
2 parents 2161958 + 36e4405 commit eb7c5fe

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

jose/jws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def _sig_matches_keys(keys, signing_input, signature, alg):
225225
def _get_keys(key):
226226

227227
try:
228-
key = json.loads(key)
228+
key = json.loads(key, parse_int=str, parse_float=str)
229229
except Exception:
230230
pass
231231

tests/test_jwt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def test_no_alg(self, claims, key):
5252
key=key,
5353
algorithms=[])
5454

55+
@pytest.mark.parametrize("key, token",
56+
[('1234567890', u'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.aNBlulVhiYSCzvsh1rTzXZC2eWJmNrMBjINT-0wQz4k'),
57+
('123456789.0',u'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.D8WLFPMi3yKgua2jm3BKThFsParXpgxhIbsUc39zJDw')])
58+
def test_numeric_key(self, key, token):
59+
token_info = jwt.decode(token, key)
60+
assert token_info == {"name": "test"}
61+
5562
def test_invalid_claims_json(self):
5663
old_jws_verify = jws.verify
5764
try:

0 commit comments

Comments
 (0)