-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Unexpected Token Expiration #236
Comments
I just checked the token in your log and it seems like the error isn't that the token is not valid anymore but instead it is not yet valid. The proper way to fix this would be to make sure the servers have matching time, however this is not always possible. If you can't guarantee synced clocks settings a couple seconds of leeway (given your small token lifetime I'd probably go with something like 5s) is a good idea. Let me know if you need more information, or feel free to close the ticket if this solved your problem. |
HI Dominik,
Thanks for the quick response, appreciate it!
Ah, should have thought to check that, good catch. Is there a "usual/common" number used for leeway as standard practice? I'm thinking 5-10 seconds?
By the way, I checked out several C++ JWT validation packages, and I liked yours the best. For me, it had one of the cleanest, and easiest to use syntax of the ones I looked at, as well as providing good standards coverage. Not to mention that it was one of the smallest because it was provided as all header files. Also, since I already liked the syntax of the nlohmann JSON package, the fact that yours integrated with it made it that much more appealing.
Thanks again for the help!
Neil
|
Will close ticket, but since the problem is very intermittent, it's tough to test for (other than in a testing environment). However, it's very likely that the few other occurrences of this (no output of the JWT in log at the time) were for the same problem. |
Not really. In a perfect world you wouldn't need leeway at all, but saidly the real world isn't perfect. Usually you wanna keep the value fairly low, cause adding leeway makes tokens valid that technically aren't valid.
Happy to hear that. If you have any other issues or improvements/feature requests, feel free to open issues for them. |
Sounds good, thanks Dominik, decided to go w/10 seconds for now to see how it goes. Will do on the suggestions, thanks again! |
Hi Dominik, Would you happen to have an example of the verifier using a network time server vs the internal clock? Thanks, |
I don't, cause normally you want the time of the entire system synced using something like NTP and not just a single part of the program. struct default_clock {
date now() const;
}; Where |
Yeah, that was my preference as well; i.e. why just get one section of code to work and not the rest of the system. However, thought I'd ask just in case. Thanks for the pointer |
I had the same issue and scratched my head until I went bald, until I got to read this page that is, thanks for the well made explanation, I would just suggest(if you haven't done it already), updating the error message from "token expired" in this case, to "token not yet valid(issue_date)", it would have helped me a ton figuring this problem by myself. |
Very occasionally, we are getting a "token expiration" error when validating a JWT token (the log times on the left column are in UTC). Is there anything obviously wrong that we're doing, or is there a possible issue here?
The version of JWT-CPP we're using is from the tag v0.6.0. The following are the pertinent sections of code we're using:
The text was updated successfully, but these errors were encountered: