Skip to content

Commit 7193e5b

Browse files
committed
Parse the claims string in JWT
So far the unverified claims of JWSs were parsed. While the claims in a JWT need to be a dict of fields, RFC7520 indicates that the claims in a JWS don't have to be. Therefore this commit parses only JWT claims into dicts.
1 parent be3d4fc commit 7193e5b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

jose/jws.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ def get_unverified_claims(token):
124124
JWSError: If there is an exception decoding the token.
125125
"""
126126
header, claims, signing_input, signature = _load(token)
127-
128-
try:
129-
return json.loads(claims.decode('utf-8'))
130-
except ValueError as e:
131-
raise JWSError('Invalid claims string: %s' % e)
127+
return claims
132128

133129

134130
def _encode_header(algorithm, additional_headers=None):

jose/jwt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ def get_unverified_claims(token):
184184
except:
185185
raise JWTError('Error decoding token claims.')
186186

187-
return claims
187+
try:
188+
return json.loads(claims.decode('utf-8'))
189+
except ValueError as e:
190+
raise JWTError('Invalid claims string: %s' % e)
188191

189192

190193
def _validate_iat(claims):

0 commit comments

Comments
 (0)