-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWE: allow general (non flattened) serialization syntax #351
JWE: allow general (non flattened) serialization syntax #351
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but please refactor the if/elif/else as described.
Also add at least 1 test where you set flattened to false and then verify that you get an object with only one recipient in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a nit to make syntax tests happy
please squash everything in a single commit with a comment that briefly explain what this change is about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just need to squash all in a single commit
0dc11ef
to
3fe1c2f
Compare
Thanks! |
A little more meat on what the change did would have been nice, but it is good enough, I will merge when tests are all green |
Thanks a lot for your help and handling this so quickly! |
Making a release is not hard work, if you have a need we can arrange to make one soon. I generally do not rush them out an instead accumulate a few changes to reduce the churn though. The only exception is security releases, I churn them out as fast as needed. |
There is no real urgency per se on our side to have a release as we have a workaround but it's not super pretty and it would ultimately be better to use this change |
When we call
.serialize()
on a JWE with 1 single recipient, it uses the flattened serialization syntax where the member of the unique recipient (header
andencrypted_key
) are added in the top-level JSON object instead of in therecipients
However, according to the RFC for JWE, the general serialization syntax allows for the JSON to have a
recipients
with only one itemIn this PR, I am adding the possibility to use the general (non flattened) serialization syntax by setting
flattened=False
when initializing theJWE
(flattened=True
is set by default)The change I did is the "easiest" one I see as it doesn't cause any breaking change and only updates the internal
objects
when adding a recipient as is expected depending on the general/flattened serialization usedWe could also:
flattened
in__init__
, always add recipient inrecipients
when calling.add_recipient
and serialize differently depending onself.flattened
when calling.serialize
recipients
when calling.add_recipient
, add a bool flagflattened
onserialize
without the check on number ofrecipients
(different ascompact
) and serialize differently depending on the flagflattened
when calling.serialize
Let me know if you prefer than I implement this in another way