rust-jwt
rust-jwt copied to clipboard
Allow to set a custom 'header content type' in the `cty` field
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
). CloningHeaderContentType::JsonWebToken
should - in my understanding - still by a copy. - It needs complete
serde::Deserialize
andserde::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?