mikkyang / rust-jwt

JSON Web Token library for Rust
MIT License
176 stars 38 forks source link

Allow custom value in `HeaderContentType` #67

Open abonander opened 3 years ago

abonander commented 3 years ago

Generating JWTs for client API access to Twilio requires setting the cty field of the JWT header to a specific magic string: https://www.twilio.com/docs/iam/access-tokens#jwt-format

cty is the content-type and encodes the version of the Access Token. Its value must be "twilio-fpa;v=1".

It would be nice not to have to implement JoseHeader for a custom type just to set this. I'm thinking an extra variant HeaderContentType::Custom(String) would be sufficient. If we want to ensure it's a properly formatted MIME type it could be mime::Mime instead but I feel like that's overkill.