在观看了大量关于 OAuth2 的教程后,每个人都反复声明了一个最佳实践——如果你有一个 React 应用程序(或 Angular,或 Ember)——你 必须使用隐式流。
我知道将客户端凭据存储在公开可见的 javascript 中是行不通的。但是,我的情况有点不同:
为了更好地理解为什么我会这么想,以下是我收到的一些可能不寻常的要求:
我无法理解为什么这个想法会那么糟糕。是否有任何技术问题可能会阻止此操作?或者可能存在安全风险?
最佳答案
The authorization code flow returns an authorization code (like it says on the tin) that can then be exchanged for an ID token and access token. This requires client authentication using a client id and secret to retrieve the tokens from the back end and has the benefit of not exposing tokens to the User Agent.
This flow allows for long lived access (through the use of refresh tokens). Clients using this flow must be able to maintain a secret.
根据您的描述,您有服务到服务的授权流程,并且由于您的服务没有公开客户端 key ,因此完全可以使用代码流程。此外,您应该使用它来允许长期存在的 token 。
关于oauth-2.0 - 如果我有服务器端代理,我可以将 Oauth2 授权代码流用于 SPA(React 应用程序)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42788267/