知识卡片

普通读书笔记卡 · 3514.c

验签与声明校验缺一不可

理解等级:中级

接受 JWT 前必须验证签名和声明:密钥与允许算法由服务端配置,aud、iss、到期时间等与本 API 的信任要求一致。签名有效但受众错误,或声明合理但签名无效,都不得放行;收到每个受保护请求均须执行有效验证。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 11 章《API authorization and authentication》(源文件:_epub-src/OEBPS/Text/11.htm) - 结论依据:原文明确签名和声明两部分均必要,并示范按预期受众及固定 RS256 算法验证。 - 原始内容:There’re two parts to validating a JWT. On one hand, you must validate its signature, and on the other hand, you must validate that its claims are correct, for example, by ensuring that the token isn’t expired and that the audience is correct.