所以这些天我正在阅读有关 OpenID
和 OAuth2
的内容。我看到了一些问题( this 和 this ),但从我读到的内容来看,您可以使用 OAuth
进行身份验证,而不仅仅是授权。关于第二个问题,我读过这个:
If you have an account (with some private resources) in a website, you can log in with username/password couple. If an application would like to get some private resources, and if you don't want to give them your username/password, use OAuth.
But if you want to log in into multiple websites with a unique account, use OpenID.
这引起了更多的困惑(Dominick Baier 在他的一次演讲中说,如果这些年你没有听说过 OAuth2
,那么你最近几年都住在山洞里,所以看起来这是我的情况):如果我有很多网络服务 (API),并且如果我有 STS
服务来为所有 API 请求 token ,那么我正在使用 OpenID
? OAuth
是否不可扩展以使用单个 STS 服务将授权扩展到多个站点?
当你试图向我解释时,请考虑我之前没有实现身份验证或授权过程。
最佳答案
你是对的:许多基于 OAuth2 的授权服务器提供了一种身份验证方法。但 OAuth2 并非为此目的而设计。 在 OAuth2 上下文中,客户端只有一个访问 token 来检索/管理资源服务器上的资源。它对资源所有者一无所知。
这就是创建 OpenID Connect 协议(protocol)的原因。它在 OAuth2 框架协议(protocol)之上工作,并允许客户端获取有关资源所有者的信息。
我推荐你看看this very interesting talk (从 4:44 开始)。该视频对我理解每个 token 的用途有很大帮助。希望对您也有帮助。
关于authentication - OAuth 与 OpenID : confused about when to use one of these and why,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41299532/