Keats / jsonwebtoken

JWT lib in rust
MIT License
1.61k stars 253 forks source link

Support Extra Key/Value Pairs in the Header #364

Closed theadd336 closed 5 months ago

theadd336 commented 5 months ago

Hello,

I was working on using jsonwebtoken to create the JWTs required for Coinbase authentication. Coinbase requires a nonce to be present in the header of the JWT, rather than the body. This seems a bit non-standard, but there is no way with either this library or jwt-simple that I have found to get the nonce into the header, though if I'm wrong, feel free to correct me. My proposal would be to add an additional header field, custom, that serde flattens. This would allow users to specify arbitrary additional metadata to the header that could be serialized.

If this seems reasonable and I'm not missing anything, I'm happy to put up the PR to do this. Just let me know.

Thanks!

theadd336 commented 5 months ago

Actually even as I type this, I think that would be a breaking change to add, as it would change Headers to require a generic type. I'm still happy to add it if it makes sense, but I can also just use a custom version of this library if you want to avoid a major version bump.

Keats commented 5 months ago

nonce is actually going to be added in https://github.com/Keats/jsonwebtoken/pull/359 for the header

theadd336 commented 5 months ago

That's great news. I'll go ahead and close this then. Thanks again.