我真的在试图理解OpenID和OAuth之间的区别?也许它们是完全不同的两件事?


当前回答

OAuth 2.0是一个安全协议。它既不是认证协议,也不是授权协议。

根据定义,身份验证回答了两个问题。

用户是谁? 用户当前是否在系统上?

OAuth 2.0具有以下授予类型

client_credentials:当一个应用程序需要与另一个应用程序交互并修改多个用户的数据时。 authorization_code:用户委托授权服务器发出access_token,客户端可以使用该token访问受保护的资源 refresh_token:当access_token过期时,可以利用刷新令牌获得一个新的access_token password:用户向调用授权服务器并接收access_token的客户机提供他们的登录凭据

这4个工具都有一个共同点,即access_token,这是一个可用于访问受保护资源的工件。

access_token没有提供“Authentication”协议必须回答的2个问题的答案。

一个解释Oauth 2.0的例子(来源:Oauth 2 in Action, Manning publications)

让我们来谈谈巧克力。我们可以用巧克力做很多甜点,包括软糖、冰淇淋和蛋糕。但是,这些都不能等同于巧克力,因为制作这种甜点还需要多种其他成分,如奶油和面包,尽管巧克力听起来像是主要成分。类似地,OAuth 2.0是巧克力,而cookie、TLS基础设施、身份提供者是提供“身份验证”功能所需的其他成分。

如果你需要身份验证,你可以使用OpenID Connect,它提供了一个“id_token”,除了access_token,它可以回答每个身份验证协议必须回答的问题。

其他回答

很多人仍然访问这个网站,这里有一个非常简单的图表来解释它

礼貌维基百科

我相信重新审视这个问题是有意义的,正如评论中所指出的,OpenID Connect的引入可能带来更多的困惑。

OpenID Connect是一种类似于OpenID 1.0/2.0的身份验证协议,但它实际上构建在OAuth 2.0之上,因此您将获得授权功能和身份验证功能。这两者之间的区别在这篇(相对较新的,但很重要的)文章中有很好的详细解释:http://oauth.net/articles/authentication/

OpenId -仅用于身份验证。

OAuth—用于身份验证和授权。授权依赖于access_token,它是JWT令牌的一部分。它可以包含用户权限的详细信息或任何有用的信息。

两者都可以依赖第三方认证提供商来维护他们的帐户。例如,OKTA身份提供者,User在OKTA登录页面上提供凭据,在成功登录时,用户被重定向到消费者应用程序,头部有JWT令牌。

更多的是对问题的延伸而不是答案,但它可能会为上面伟大的技术答案增加一些视角。我是一个在很多领域都很有经验的程序员,但是在网页编程方面完全是个新手。现在尝试使用Zend框架构建一个基于web的应用程序。

Definitely will implement an application-specific basic username/password authentication interface, but recognize that for a growing number of users the thought of yet another username and password is a deterrent. While not exactly social networking, I know that a very large percentage of the application's potential users already have facebook or twitter accounts. The application doesn't really want or need to access information about the user's account from those sites, it just wants to offer the convenience of not requiring the user to set up new account credentials if they don't want to. From a functionality point of view, that would seem a poster child for OpenID. But it seems that neither facebook nor twitter are OpenID providers as such, though they do support OAuth authentication to access their user's data.

在我读过的所有关于这两者及其区别的文章中,直到我看到上面Karl Anderson的观察,“OAuth可以用于身份验证,这可以被认为是一种无操作授权”,我才看到任何明确的确认OAuth足以满足我想要做的事情。

In fact, when I went to post this "answer", not being a member at the time, I looked long and hard at the bottom of this page at the options for identifying myself. The option for using an OpenID login or obtaining one if I didn't have one, but nothing about twitter or facebook, seemed to suggest that OAuth wasn't adequate for the job. But then I opened another window and looked for the general signup process for stackoverflow - and lo and behold there's a slew of 3rd-party authentication options including facebook and twitter. In the end I decided to use my google id (which is an OpenID) for exactly the reason that I didn't want to grant stackoverflow access to my friends list and anything else facebook likes to share about its users - but at least it's a proof point that OAuth is adequate for the use I had in mind.

It would really be great if someone could either post info or pointers to info about supporting this kind of multiple 3rd-part authorization setup, and how you deal with users that revoke authorization or lose access to their 3rd party site. I also get the impression that my username here identifies a unique stackoverflow account that I could access with basic authentication if I wanted to set it up, and also access this same account through other 3rd-party authenticators (e.g. so that I would be considered logged in to stackoverflow if I was logged in to any of google, facebook, or twitter...). Since this site is doing it, somebody here probably has some pretty good insight on the subject. :-)

很抱歉这篇文章写了这么长时间,而且更多的是一个问题而不是一个答案——但是Karl的评论似乎是在OAuth和OpenID上大量的帖子中最合适的地方。如果我没有找到更好的地方,我提前道歉,我确实试过了。

创建这两个协议的原因不同。创建OAuth是为了授权第三方访问资源。创建OpenID是为了执行分散的身份验证。本网站说明如下:

OAuth是一种用于验证终端用户身份并向第三方授予权限的协议。这个验证的结果是一个令牌。第三方可以使用这个令牌来代表用户访问资源。令牌有一个作用域。作用域用于验证用户是否可以访问某个资源

OpenID是用于分散身份验证的协议。认证是关于身份的;确定用户实际上就是他所声称的那个人。去中心化意味着该服务不知道需要保护的任何资源或应用程序的存在。这就是OAuth和OpenID之间的关键区别。