-
Notifications
You must be signed in to change notification settings - Fork 318
Custom header support #444
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
base: master
Are you sure you want to change the base?
Conversation
|
I believe that #445 is far more elegant for this. What do you think? |
|
@mathstuf, it looks like #445 only adds a standalone function to decode a custom header, it doesn't provide any integration with the existing code or any tests. It's worth noting that |
|
Hmm, ok. I'll take a look at |
c6bca67 to
b012686
Compare
Add true support for custom headers with full backwards compatibility.
Add `Header` derive macro, `header` attribute macro, and `claims` attribute macro. `Header` derive macro implements required traits for custom headers `header` and `claims` are convenience attribute macros that add the required derive macros.
b012686 to
a606eac
Compare
I think a single |
|
No I definitely don't want to add a proc macro |
|
I think the proc macro is overkill for 99% of the users and would rather have people using the type defined in the crate |


In service of #439
Adds support for custom headers via
decode_with_custom_headerto decode and validate JWT, and a standalone header-only decode viadecode_custom_header. Those should probably have better names before this is merged. The existingdecodeanddecode_headerfunctions retain full backwards compatibility.Also adds convenience macros for claims and custom headers,
jsonwebtoken::macros::claimsandjsonwebtoken::macros::header, and aHeaderderive macro.Adds a
BasicHeaderto fulfill #439 (i.e. implementHash). I have mixed feelings on that one. I think ideallyextraswouldn't exist on the originalHeaderstruct, which was itself a breaking change (#420) due to removing theHashimplementation, but removing it now would be a breaking change. Given those constraints, adding aBasicHeaderis the only path I could think of to resolve #439 and also to avoid the minor performance hit of using a HashMap (along w/ the inherent risk of a malicious user intentionally sending JWTs with abnormally large headers containing a large number fields).