Skip to content

Commit 00c51d7

Browse files
committed
Make sure the parsed claims are a JSON object
1 parent 126f07b commit 00c51d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jose/jwt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,15 @@ def get_unverified_claims(token):
185185
raise JWTError('Error decoding token claims.')
186186

187187
try:
188-
return json.loads(claims.decode('utf-8'))
188+
claims = json.loads(claims.decode('utf-8'))
189189
except ValueError as e:
190190
raise JWTError('Invalid claims string: %s' % e)
191191

192+
if not isinstance(claims, Mapping):
193+
raise JWTError('Invalid claims string: must be a json object')
194+
195+
return claims
196+
192197

193198
def _validate_iat(claims):
194199
"""Validates that the 'iat' claim is valid.

0 commit comments

Comments
 (0)