Skip to content

Commit 5cc042f

Browse files
committed
Make it possible to wrap the payload in a message class dependent on the header parameter "typ".
1 parent 7667404 commit 5cc042f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cryptojwt/jwt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def __init__(
112112
self.with_jti = False # If a jti should be added
113113
# A map between issuers and the message classes they use
114114
self.iss2msg_cls = iss2msg_cls or {}
115+
self.typ2msg_cls = typ2msg_cls or {}
115116
# Allowed time skew
116117
self.skew = skew
117118
# When verifying/decrypting
@@ -396,7 +397,7 @@ def unpack(self, token, timestamp=None):
396397
else:
397398
# try to find an issuer specific message class
398399
_msg_cls = self.iss2msg_cls.get(_info["iss"])
399-
if not _msg_cls:
400+
if not _msg_cls and 'typ' in _jws_header:
400401
_msg_cls = self.typ2msg_cls.get(_jws_header['typ'])
401402

402403
timestamp = timestamp or utc_time_sans_frac()

0 commit comments

Comments
 (0)