RFC6749 Oauth2.0 阅读笔记

栏目: 后端 · 前端 · 发布时间: 6年前

内容简介:最近有facebook好友的接入工作,重读了一遍oauth2.0。相较第一次读,对四种授权模式,主要是Authorization Code, Implicit Grant有了正确的理解。所以有了这篇。关键是,OAuth 引入了一个授权层,用来分离两种不同的角色:客户端和资源所有者。从而资源所有者(用户)的credentials,主要是密码,不会暴露给客户端。

为啥要写这篇

最近有facebook好友的接入工作,重读了一遍oauth2.0。相较第一次读,对四种授权模式,主要是Authorization Code, Implicit Grant有了正确的理解。所以有了这篇。

1. 为什么需要Oauth2

https://tools.ietf.org/html/r...

OAuth addresses these issues by introducing an authorization layer
   and separating the role of the client from that of the resource
   owner.  In OAuth, the client requests access to resources controlled
   by the resource owner and hosted by the resource server, and is
   issued a different set of credentials than those of the resource
   owner.

关键是,OAuth 引入了一个授权层,用来分离两种不同的角色:客户端和资源所有者。从而资源所有者(用户)的credentials,主要是密码,不会暴露给客户端。

2. four roles

https://tools.ietf.org/html/r...

resource owner

An entity capable of granting access to a protected resource. When the resource owner is a person, it is referred to as an end-user.

资源拥有者, 如豆瓣用户,假设认证服务器是微信。

resource server

The server hosting the protected resources, capable of accepting and responding to protected resource requests using access tokens.

用户访问的网站,如豆瓣。

client

An application making protected resource requests on behalf of the resource owner and with its authorization. The term "client" does not imply any particular implementation characteristics (e.g., whether the application executes on a server, a desktop, or other devices).

客户端,是一个程序,代表资源拥有者的用其授权发起资源访问,可以在桌面上的浏览器,手机端的app,服务器上运行。

authorization server

The server issuing access tokens to the client after successfully authenticating the resource owner and obtaining authorization.

在认证,授权成功后,发放访问token至客户端, 如微信发放访问token至豆瓣。

RFC6749 Oauth2.0 阅读笔记

3. client

todo 结合facebook开发者文档,结合具体参数,分析为什么要这么做。

4. four grant types

https://tools.ietf.org/html/r...

四种获得授权的方式,即client如何拿到access token.

An authorization grant is a credential representing the resource
   owner's authorization (to access its protected resources) used by the
   client to obtain an access token. This specification defines four
   grant types -- authorization code, implicit, resource owner password
   credentials, and client credentials -- as well as an extensibility
   mechanism for defining additional types.

Authorization Code

https://tools.ietf.org/html/r...

关键在于authorization code只可使用一次,假设resource owner到client的链接为http,可能被窃听。

因为到authorization server的链接是https, access_token绝不会被暴露,而授权码就算被暴露,也会因用户的充登,而让此前中间人获取的access_token失效。

RFC6749 Oauth2.0 阅读笔记

Implicit Grant

https://tools.ietf.org/html/r...

相较Authorization Code,authorization server直接返回access token, 关键点在于access token在callback中,以fragment方式返回access token,这样,user-agent访问Web-Hosted Client Resource时,不会带上access token,access token留在本地,注意这种情况下client也在本地。

Resource Owner Password Credentials Grant

https://tools.ietf.org/html/r...

用户相当信任client,直接给密码client,client用密码获得access token.

Client Credentials Grant

https://tools.ietf.org/html/r...

authorization server完全相信client,client通过证书直接拿access token

参考


以上所述就是小编给大家介绍的《RFC6749 Oauth2.0 阅读笔记》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

失控

失控

[美] 凯文·凯利 / 东西文库 / 新星出版社 / 2011-3 / 98.00元

2006年,《长尾理论》的作者克里斯·安德森在亚马逊网站上这样评价该书: “这可能是90年代最重要的一本书”,并且是“少有的一年比一年卖得好的书”。“尽管书中的一些例子在十几年后可能有些过时,但(它们所表达的)信息却越来越成为真知灼见”。“在那时人们还无法想象博客和维基等大众智慧的突起,但凯利却分毫不差地预见到了。这可能是过去十年来最聪明的一本书。” 这是《黑客帝国》主要演员的必读物之......一起来看看 《失控》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器