使用 JWT 进行 API 请求是否很弱,因为用户拥有令牌并且可以重复使用它?

问题描述 投票:0回答:1

JWT 提供的唯一安全性就像它们生成的令牌在几秒钟或几分钟内有效(我们可以设置),但是当用户发送带有生成的 JWT 令牌的请求时,黑客可以轻松地在浏览器中侦听该请求 - >检查 - > 联网并重放攻击,即使令牌的有效期只有 30 秒,重放攻击仍然有很多时间。

我尝试使用加密的有效负载发送我的请求,黑客可能无法查看有效负载,但他仍然可以重放攻击以扰乱我的功能/计算。

node.js networking jwt network-security
1个回答
0
投票

您的 JWT 只能使用一次,因此在发送到 SP 后,它将立即失效并且不再被接受。这意味着您的 SP 也需要访问您列入黑名单的 JWT。

当然,您可能需要在 JWT 中嵌入刷新令牌,以便 SP 能够将请求反向发送到 IDP。

所以,IDP 上的算法:

if session does not exist then
    try to authenticate the identity
end if
if the identity has a valid session then
    send out a JWT
    synchronize with the SP
    once the JWT has been received, invalidate it
end if

在 SP

send request to IDP
receive JWT
if valid, then
    authenticate
end if
© www.soinside.com 2019 - 2024. All rights reserved.