gpt4 book ai didi

jwt - 为什么客户端需要解密JWE?

转载 作者:行者123 更新时间:2023-12-05 04:09:56 25 4
gpt4 key购买 nike

如果我使用 JWE 发送加密的 JSON 消息,该消息将存储在客户端以供授权使用,为什么客户端需要解密此消息?

客户端将 JWE token 附加到所有请求。服务器使用 JWE token 识别客户端并响应或拒绝请求。自始至终,只有服务器才能解密。

如果这个结构没有问题,那么最好的实现方式是什么?我是否应该使用非对称加密而不提供公钥(这在 JWE 规范中是否可行)?

按照这些思路,确保 JWE token 未被拦截且虽然未被解密但附加到恶意服务器请求的最佳方法是什么,从而有效地允许攻击者冒充客户端?

此外,还有其他我遗漏的安全问题吗?

最佳答案

If I'm using JWE to send an encrypted JSON message, which will be stored on the client-side, for use with authorization, why would the client need to decrypt this message?

当客户端需要读取JWT中包含的一些数据时,比如用户id或者过期时间。这并非在所有情况下都需要。

Client attaches the JWE token to all requests. Server identifies client using JWE token and responds or denies request.

是的,这是通常的授权流程

Throughout, only the server can decrypt.

不一定。服务器可以使用接收方的公钥加密加密 key ,例如使用 RSAES-OAEP。然后接收者将能够用他的私钥解密 JWT

If there's no problem with this structure, what's the best way to implement it? Should I use asymmetric encryption and not provide a public key (is this possible within the JWE spec)?

这取决于您的要求。如果您希望客户端可以解密 JWT,您需要提供 key 或使用非对称加密并将消息加密给收件人

Along these lines, what's the best way to ensure the JWE token hasn't been intercepted and, though not decrypted, attached to a malicious server request, effectively allowing an attacker to impersonate the client?

拥有 JWT 是身份验证证明。如果 token 被盗,则攻击者可以冒充用户。因此,您需要保护它以降低风险:

  • 主要使用HTTPS加密通讯 channel

  • 安全地存储在客户端。

关于jwt - 为什么客户端需要解密JWE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45171615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com