服务器不能只是将临时凭证“升级”为 token 凭证并保留相同的 key 和 secret 吗?
然后,客户端可以在收到来自服务器的说明临时凭据已“升级”的回调后立即开始进行经过身份验证的调用。
当然,如果临时凭据尚未升级(即客户端不等待回调),则经过身份验证的调用将失败。
所以问题是为什么在回调后对服务器进行额外调用以“交换” token 凭据的临时凭据?
最佳答案
您可以通过这种方式实现 OAuth,但据我所知,将请求 token 与访问 token 分开确实提供了额外的安全层。
来自 Beginner's Guide :
OAuth includes two kind of Tokens: Request Token and Access Token. Each Token has a very specific role in the OAuth delegation workflow. While mostly an artifact of how the OAuth specification evolved, the two-Token design offers some usability and security features which made it worthwhile to stay in the specification. OAuth operates on two channels: a front-channel which is used to engage the User and request authorization, and a back-channel used by the Consumer to directly interact with the Service Provider. By limiting the Access Token to the back-channel, the Token itself remains concealed from the User. This allows the Access Token to carry special meanings and to have a larger size than the front-channel Request Token which is exposed to the User when requesting authorization, and in some cases needs to be manually entered (mobile device or set-top box).
因此,据我所知,通过将访问 token 直接限制在消费者(您的服务)和提供者(您正在访问的服务)之间的 channel ,您可以获得一个安全的访问 token (即攻击者没有),即使用户的机器或用户与您的服务的网络连接被破坏。如果请求 token 被简单地升级,那么任何嗅探用户网络连接的人都可以轻松获得请求/访问 token ,我们希望对其保密,因为它可以被使用(当然,与您的消费者 token 一起使用),可能用于很长时间,才能访问用户的数据。服务器到服务器的连接通常更安全。
此外,正如上面所指出的,在请求 token 实际上必须由用户输入的情况下,这使您可以拥有更长的 key (因此可能很短)。
关于oauth - 为什么我们必须在 OAuth 中使用 "change temporary credentials for token credentials"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2377541/