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

Use OrderedDict for headers in jwt.decode and jws._encode_header #80

Closed
Fufutako opened this issue Feb 7, 2018 · 2 comments · Fixed by #136
Closed

Use OrderedDict for headers in jwt.decode and jws._encode_header #80

Fufutako opened this issue Feb 7, 2018 · 2 comments · Fixed by #136

Comments

@Fufutako
Copy link

Fufutako commented Feb 7, 2018

Hello,

I would implement the "headless JWT" idea I rode in this article https://dev.to/neilmadden/7-best-practices-for-json-web-tokens the section 4 "Consider using "headless" JWTs" .

But the fact python-jose build the headers from dict make this impossible. Indeed, keys don't have an order in a classic dict. Could you consider to use OrderedDict instead, in jws.py l.131 and jwt.py l.114 ?

If this idea interests you, I could make a pull request.

Best,

@zejn
Copy link
Collaborator

zejn commented Feb 7, 2018

If I understand you correctly, the keys need need to be predictable for this to work. Would adding the sort_keys=True parameter to json.dumps be enough?

@Fufutako
Copy link
Author

Fufutako commented Feb 7, 2018

yes why not ... I do that with an OrderedDict but sort_key in the dumps works too

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 a pull request may close this issue.

2 participants