OAuth 2 是协议还是框架?

OAuth 2 is a protocol or a framework?

实际上,我的问题在 post 本身的标题中。 所以,实际上,在 RFC OAuth 中称为框架,但在很多文章中,它称为协议。那么什么是正确的名称,为什么?

据我所知,协议是一组规则 - 在这种情况下它似乎是相关的。在框架下,我通常会理解一些组件(例如编程语言类)的集合,这对某些过程(例如开发)会有所帮助。

有人可以向我解释一下吗?非常感谢!

来自 IETF 网站:

Memos in the Requests for Comments (RFC) document series contain technical and organizational notes about the Internet. They cover many aspects of computer networking, including protocols, procedures, programs, and concepts, as well as meeting notes, opinions, and sometimes humor.

例如,1981 年发布的 RFC 791 描述了互联网协议。它描述了它是如何工作的,并提供了伪代码,描述了协议应该如何实现。它不提供 "framework" 或 "toolset" 意义上的任何代码,也没有说明应如何设计实际的 Internet 路由器。

RFC 6749 (OAuth 2) 也是如此 - RFC 描述了协议并讨论了协议的实施方式。

在 OAuth 的情况下,RFC 或多或少将协议和框架视为同义词。同样的事情发生在例如在 oauth.net 网站上,甚至在首页上。 RFC 本身的名称是 "The OAuth 2.0 Authorization Framework"。因此,语义上 我认为 "protocol" 和 "framework" 在这种情况下都是正确的。

但在实践中,您可以将 RFC 视为 "protocol definition",将不同语言上的实际协议实现(您可以利用)视为 "frameworks",您在问题中描述的含义。

为了得到一个很好的解释,我认为值得观看 Eran Hammer 关于 OAuth 2.0 的后续视频。

https://vimeo.com/52882780

到这里,你就可以理解为什么RFC 6749的标题改为Framework而不是Protocol了。简而言之,OAuth 2.0 不可互操作,详见 section 1.8 from RFC 6749:

However, as a rich and highly extensible framework with many optional components, on its own, this specification is likely to produce a wide range of non-interoperable implementations.

我希望这能更好地帮助您理解。