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

why the exp and iat put in the header section of the jwt? #73

Closed
ghost opened this issue Nov 9, 2016 · 17 comments
Closed

why the exp and iat put in the header section of the jwt? #73

ghost opened this issue Nov 9, 2016 · 17 comments

Comments

@ghost
Copy link

ghost commented Nov 9, 2016

I read the latest offical doc
and font that exp and iat is usually put in the payload part instead of header section.
should I use this or remove it and pyjwt instead??

@untitaker untitaker changed the title why the exp and iat put in the header section of the jwt??? why the exp and iat put in the header section of the jwt? Nov 9, 2016
@untitaker
Copy link
Contributor

That appears to be an oversight, yeah!

@davidism
Copy link
Member

davidism commented Nov 9, 2016

itsdangerous implements JWS (with some extra headers in the timed case), not JWT.

Looking at the JWS spec, the only reference I can find to the headers you mention is in the payload of one of the example, where the payload is unrelated to the example. JWS itself doesn't define a payload format so it can't define how to store those fields there.

You appear to be looking at the JWT spec in the "claims" section.

@davidism davidism closed this as completed Nov 9, 2016
@untitaker
Copy link
Contributor

Oops sorry, I didn't really see that either!

@reubano
Copy link

reubano commented Nov 12, 2016

@davidism is there any disadvantage to implementing JWT in this case? If JWS doesn't say one way or the other, it seems like it would make the most sense to follow JWT. CR #19.

@untitaker untitaker reopened this Nov 12, 2016
@untitaker
Copy link
Contributor

I didn't see that part. I think we could just cut a new release with the change though that will invalidate all Flask sessions.

@reubano
Copy link

reubano commented Nov 12, 2016

I think we could just cut a new release with the change though that will invalidate all Flask sessions.

Isn't that what semver is for?

@untitaker
Copy link
Contributor

Yes of course

@davidism
Copy link
Member

I don't understand why this was reopened. You're still looking at JWT, not JWS. Just because we added extra headers (which is allowed in the spec) that are similar to JWT claims, doesn't make this JWT. Changing the current implementation would force all payloads to be dicts. As I've said in other issues about JWT and JWE, I'm fine with adding more serializers, if someone wants to implement one.

@untitaker
Copy link
Contributor

Yes but the pr linked by @reubano indicated that Armin intended to implement JWT

@davidism
Copy link
Member

davidism commented Nov 12, 2016

Yeah, I understand that, at the time I guess the specs were ambiguous so they ended up with JWS with the time extension. Again, adding a separate serializer seems fine to me, now that everything's settled, but that's not what this issue was about.

@davidism
Copy link
Member

If we do want to implement more of the JW* specs, I'd like to see this split into a package, it's already pretty unwieldy as a single file.

@davidism
Copy link
Member

davidism commented Nov 12, 2016

The intention of that other issue always seems to have been JWS, based on the name. Armin seems to just be commenting on the fact that JWT has a spec for timing that JWS lacks. I agree with his other observation that this whole thing is a mess. 🙁

@untitaker
Copy link
Contributor

Whatever it is, I think we should decide on supporting JWT to end this once and for all.

@ghost
Copy link
Author

ghost commented Nov 15, 2016

seems I misunderstood the code..
I don't know it's jws instead of jwt ..
and please support that although I can use pyjwt.
but an official support save more time.

@ptallada
Copy link

ptallada commented Jan 4, 2017

Hi,

Please, move exp and iat to payload, otherwise it is incompatible with JWT specs and (at least) angular-jwt
Also it affects flask-jwt (pallets-eco/flask-jwt#40)

Thanks!

@davidism
Copy link
Member

davidism commented Jan 4, 2017

Contributions are welcome, but as stated we're not breaking the JWT spec because we're following the JWS spec.

@davidism
Copy link
Member

Closing this.

The current serializer implements JWS, not JWT. The JWS spec does not include expiration, but does allow extra keys in the header, and we use that. If you're having trouble parsing a token, make sure whatever library you're using is parsing JWS, not JWT.

I also difficult to justify the added maintenance burden to implement and support JWT, when there are other Python projects that implement it. If you'd like to use JWT with the API provided by ItsDangerous, there are enough customization points to plug your JWT library of choice into a new Serializer subclass.

@pallets pallets locked as resolved and limited conversation to collaborators Oct 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants