Skip to content

Commit

Permalink
fix(jwe): fix when there is no encrypted_key
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 9, 2023
1 parent 78f4c9d commit 1e77df0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/joserfc/rfc7516/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ def extract_json(data: JSONSerialization) -> JSONEncryption:
obj.flatten = False
for item in data["recipients"]:
recipient = Recipient(obj, item.get("header"))
recipient.encrypted_key = urlsafe_b64decode(to_bytes(item["encrypted_key"]))
if "encrypted_key" in item:
recipient.encrypted_key = urlsafe_b64decode(to_bytes(item["encrypted_key"]))
obj.recipients.append(recipient)
else:
obj.flatten = True
recipient = Recipient(obj, data.get("header"))
recipient.encrypted_key = urlsafe_b64decode(to_bytes(data["encrypted_key"]))
if "encrypted_key" in data:
recipient.encrypted_key = urlsafe_b64decode(to_bytes(data["encrypted_key"]))
obj.recipients.append(recipient)
return obj

0 comments on commit 1e77df0

Please sign in to comment.