-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
validating issued_at alway return token expired? #14
Comments
Sorry for the long delay. iat is the time where the token was created. I might have understood your issue wrong, can you please provide more information on your concern ? |
thank you for responding generously, i think you show up the problem...i m testing the verify function where the iat and the current time is separate by a few seconds .... I always got token expired exception |
Yeah the message might be a bit missleading. |
iat = 2019-04-08 14:30:24-04 but validation failed at if (time < iat - std::chrono::seconds(leeway)) |
@mdy405 That should indeed be fine. Ill take a look later and test it. |
@mdy405 I can't reproduce the issue. Can you send me a sample token for debugging purposes? |
try this one : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJhdWQiOiJhcHBsaWNhdGlvbl90ZXN0IiwiZGV2aWNlIjoiZGV2aWNlX3Rlc3QiLCJleHAiOjE1NTQ3NDk0OTEsImlhdCI6MTU1NDc1MjE5MSwiaXNzIjoiUFNsaWNlbmNlIiwibGFuZyI6IiIsInNlc3Npb24iOiJlMWM4Zjg4Yi1mMGExLTQ3NjgtYjYwNS01OGU2MGJjNzNiMTMiLCJzdWIiOiIyIn0.IC0Ycv_essCYeSsbxQuuH42RLGr8bjj5b-g-OQpzoIw" |
Do you use jwt-cpp for creating that token? |
yes i use jwt-cpp like below: (now is a string formatted datetime)
|
@mdy405 I cleaned your code a bit and added a static time.
Maybe you mixed up set_expires_at and set_issued_at ? It is generating a valid token and the issue is not present there, are you sure the code you posted is the code you use to generate the token? You can check your token here: |
it's definitely weird i used the same code but unable to validate the token! |
I think i found the issue for some unknown reason(at the moment) i got a bad timestamp while converting my string to timepoint. i got: @Thalhammer is that right, the current time used to verify the token is UTC ? but i use local time to set iat and eat, do you think it can cause the issue? |
@mdy405 but those look right ;) |
Is this solved @mdy405 ? |
Closed due to inactivity. |
if (jwt.has_issued_at()) { auto leeway = claims.count("iat") == 1 ? std::chrono::system_clock::to_time_t(claims.at("iat").as_date()) : default_leeway; auto iat = jwt.get_issued_at(); if (time < iat - std::chrono::seconds(leeway)) throw token_verification_exception("token expired"); }
leeway = 0 so time < iat! who else got this ?
The text was updated successfully, but these errors were encountered: