知识卡片
验签之外还需核对令牌声明
资源服务收到 JWT 后,不能只验证签名。还应核对发行方、目标受众、有效期及生效时间是否符合本 API 的信任关系;短有效期可降低令牌泄露后的可用窗口。具体声明和容忍时钟偏差需按系统策略明确。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
When the JWT is received, there are multiple parts to verify. First, the signature is checked to confirm that it was issued from the expected party and has not been modified or tampered with. Then other claims in the token should be validated, such as checking that the token has not expired (exp claim) or that the token is not used before it is allowed (nbf claim).
参考来源
- 位置:《Mastering API Architecture》第7章《API Authentication and Authorization》之《JSON Web Tokens (JWT)》(源文件:_epub-src/OEBPS/ch07.xhtml)
- 结论依据:原文列出 iss、aud、exp、nbf 等声明,要求接收方检查签名和时间声明,说明长寿命令牌丢失风险更高。
- 原始内容:When the JWT is received, there are multiple parts to verify. First, the signature is checked to confirm that it was issued from the expected party and has not been modified or tampered with. Then other claims in the token should be validated, such as checking that the token has not expired (exp claim) or that the token is not used before it is allowed (nbf claim).