Skip to content
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

Allow to set a custom 'header content type' in the cty field #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

themasch
Copy link

rfc7519 specifies only one valid value for the cty field in the header: "JWT", meaning the payload itself is another complete JWT.
This change supports setting cty to something else (any string) by constructing the header with Some(HeaderContentType::Custom("...")).

This should solve #67. The implementation here comes with a few (minor?) problems:

  • HeaderContentType is no longer Copy, since it now contains a String. I was not able to prevent this without changing the public interface. As far as I can see this only means we have to do a clone operation whenever a HCT::Custom is copied (i.e. JoseHeader::content_type). Cloning HeaderContentType::JsonWebToken should - in my understanding - still by a copy.
  • It needs complete serde::Deserialize and serde::Serialize implementations, since I was not able to find a way to make serde flatten the the Custom enum variant in any other way.

... so one could argue, every change this PR introduces is a problem?

But maybe it solves a real use case for an acceptable cost?

rfc7519 specifies only one valid value for the `cty` field in the header: "JWT", meaning the payload itself is another complete JWT.
This change supports setting `cty` to something else (any string) by constructing the header with `Some(HeaderContentType::Custom("..."))`.
franklinblanco added a commit to franklinblanco/rust-jwt that referenced this pull request Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants