JWT 令牌 expiresIn 如何在羽毛中工作? [英] How JWT token expiresIn works in feathers?
问题描述
当我解码我在有效负载中看到的 JWT 令牌时
When I decode my JWT token I see in payload
{
"exp": 1494105589
}
它的价值是什么意思?文档说默认的 JWT expiresIn 值是1d",但它似乎不是创建令牌后的 1 天,甚至不是 1 天(以毫秒为单位)(1000*60*60*24).最糟糕的是:当我在我的配置中设置 "expiresIn": "90d" 时,这个值没有太大变化.有人能解释一下吗?
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?
推荐答案
这是一个 unix 时间戳,计算自 1970 年 1 月 1 日 00:00 UTC 以来的秒数.有几个网站可以帮助您转换价值,例如.这个:http://www.unixtimestamp.com/index.php对于您的时间戳,它显示 05/06/2017 @ 9:19pm (UTC),因此您的令牌有效期为 5 个月.
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://www.rfc-editor.org/rfc/rfc7519#section-4.1.4说明 数字日期 用于 exp 声明(也用于 nbf(不是之前)和 iat(发布于)声明)
https://www.rfc-editor.org/rfc/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://www.rfc-editor.org/rfc/rfc7519#section-2定义数字日期:
一个 JSON 数值,表示从 1970-01-01T00:00:00Z UTC 到指定 UTC 日期/时间的秒数,忽略闰秒.
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.
除了你说的
最糟糕的是:当我设置expiresIn"时,这个值没有太大变化:90d"在我的配置中.
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 }
如果是,expires_in 是否显示正确的值?
and if yes, did expires_in show the correct value ?
这篇关于JWT 令牌 expiresIn 如何在羽毛中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!