-
Notifications
You must be signed in to change notification settings - Fork 995
"Token used before issued" when checking 'iat' #314
Comments
I originally was a few milliseconds off (the now and iat stamps), now they are consistently the same. |
Issued at checking will be removed in v4, per the jwt spec. |
@dgrijalva is there a workaround available now? I'm also seeing this issue on a small amount of requests. |
Simplest workaround is probably to wrap your claims type in something custom that bypasses the IAT check. Here's a lazy example I didn't actually test. Something like the following should work: type MyClaims struct {
*jwt.StandardClaims
}
func (c *MyClaims) Valid()bool {
var leeway = 10
c.StandardClaims.IssuedAt -= leeway
valid := c.StandardClaims.Valid()
c.StandardClaims.IssuedAt += leeway
return valid
} |
FWIW - I had this problem and it turned out to be the internal clock on my EC2 instance. Following this guide solved the problem. |
Ran into this as well, any plans to support some amount of clock drift? 0 - 500ms isn't that uncommon with ntp. |
Another workaround:
|
There's a caveat for @pawelkowalak's suggestion in that request.ParseFromRequest(..., func(token *jwt.Token) (interface{}, error) {
mapClaims := token.Claims.(jwt.MapClaims)
delete(mapClaims, "iat")
// ...
}) This approach works because the keyFunc callback is called internally in the library before running validation. This allows using the callback to modify the claims after it has been created but before it's being validated. |
h/t dgrijalva/jwt-go#314 (comment) Signed-off-by: Manfred Touron <[email protected]>
h/t dgrijalva/jwt-go#314 (comment) Signed-off-by: Manfred Touron <[email protected]>
I have out of sync problem.
Time on php server is different for a fraction of a second and because of this there is a problem when checking the token
Token used before issued
.Is it possible to make the check less strict?
I used this workaround:
What would you advise me?
The text was updated successfully, but these errors were encountered: