How JWT token expiresIn works in feathers?

2020-02-16 03:13发布

问题:

When I decode my JWT token I see in payload

{
  "exp": 1494105589
}

What does it value means? Docs says that default JWT expiresIn value is "1d" but it's not seems like 1 day after token created and even not 1 day in ms (1000*60*60*24). And the worst: this value not changed much when I set "expiresIn": "90d" in my config. Could somebody give some explanation of this?

回答1:

it's a unix timestamp, counting the seconds since 1st of January 1970 00:00 UTC. There are several websites that help you to convert the value, eg. this one : http://www.unixtimestamp.com/index.php For your timestamp it says 05/06/2017 @ 9:19pm (UTC), so your token is valid for 5 month.

https://tools.ietf.org/html/rfc7519#section-4.1.4 explains that a numeric date is used for the exp claim (and also for the nbf (not before) and iat (issued at) claims)

https://tools.ietf.org/html/rfc7519#section-2 defines the numeric date:

A JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds.

beside that you said

And the worst: this value not changed much when I set "expiresIn": "90d" in my config.

when you got the token, did it come in a structure like this :

{"access_token": "eyJhbGciOiJ...", "token_type": "bearer", "expires_in": 86399 }

and if yes, did expires_in show the correct value ?