在 OAuth2 密码流中使用 Hashicorp Vault 存储客户端 ID 和密码

Using Hashicorp Vault for storage of client id and secret in OAuth2 Password Flow

我是 Hashicorp Vault 的新手。我希望使用 Hashicorp Vault 为 OAuth2 密码流保护我的客户端 ID 和密码。每次调用我的后端 REST API 时,它都需要客户端 ID 和密码,以及用户名和密码的用户凭据。我如何以安全的方式执行此操作并且只让我的应用程序通过它而不在我的 javascript 客户端中披露它?

谢谢。

约翰

如果我没看错你的问题,你有一个 Javascript 应用程序调用你自己的 (REST) 后端服务。该调用使用客户端 ID、客户端密码、用户名和密码进行保护。这引发了几个问题:

client id and secret, as well as the user credentials of username and password

这似乎是错误的做法:OAuth 保护的资源(您的 REST 后端服务)不应要求用户名和密码。用户登录在授权服务器中完成。

尝试从阅读 OAuth2 规范开始(RFC 6749) or the DigitalOcean tutorial 以获得全面的概述。

How would I do this in a secure way and only let my app pass this without disclosing this in my javascript client?

您不能:客户端机密无法在客户端控制的应用程序中得到保护,因为恶意客户端可以对您的应用程序进行逆向工程(或读取您的 javascript)。您拥有的称为“public 客户端”,即无法保密的客户端。在这种情况下,您不使用客户端机密。尝试从 this question or the introduction to oauth2 client types.

开始