Oauth1.0认证过程
现今,已经有了Oauth2.0,写篇博客了解Oauth1.0的过程以及与2.0的区别。
在Oauth官网 关于1.0的介绍:
一、简介
OAuth authentication is the process in which Users grant access to their Protected Resources without sharing their credentials(证书) with the Consumer. OAuth uses Tokens generated by the Service Provider instead of the User’s credentials in Protected Resources requests. The process uses two Token types:
整个认证的过程是,用户通过共享证书的方式,将自己的受保护的资源授权给使用者使用。通过使用服务提供商提供的Tokens代替用户的证书来访问受保护的资源。
- Request Token:
- Used by the Consumer to ask the User to authorize access to the Protected Resources. The User-authorized Request Token is exchanged for an Access Token, MUST only be used once, and MUST NOT be used for any other purpose. It is RECOMMENDED that Request Tokens have a limited lifetime.
- Access Token:
- Used by the Consumer to access the Protected Resources on behalf of the User. Access Tokens MAY limit access to certain Protected Resources, and MAY have a limited lifetime. Service Providers SHOULD allow Users to revoke Access Tokens. Only the Access Token SHALL be used to access the Protect Resources.
二、认证过程
OAuth Authentication is done in three steps:
- The Consumer obtains an unauthorized Request Token.
- The User authorizes the Request Token.
- The Consumer exchanges the Request Token for an Access Token
下面是官方提供的流程图:
1、Customer Requests --- Request Token
To obtain a Request Token, the Consumer sends an HTTP request to the Service Provider’s Request Token URL. The Service Provider documentation specifies the HTTP method for this request, and HTTP POST is RECOMMENDED. The request MUST be signed and contains the following parameters:
- oauth_consumer_key:
- The Consumer Key.
- oauth_signature_method:
- The signature method the Consumer used to sign the request. -- 用来签署该次请求 HMAC-SHA1, RSA-SHA1, and PLAINTEXT 三种签名方法。
- oauth_signature:
- The signature as defined in Signing Requests. -- 防止使用者使用未经授权的保护资源。
- oauth_timestamp:
- As defined in Nonce and Timestamp.
- oauth_nonce:
- As defined in Nonce and Timestamp. A nonce is a random string, uniquely generated for each request.
- oauth_version:
- OPTIONAL. If present, value MUST be 1.0 . Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present. Service Providers’ response to non-1.0 value is left undefined.
- Additional parameters:
- Any additional parameters, as defined by the Service Provider.
-
2、Service Provider Issues an Unauthorized Request Token
The Service Provider verifies the signature and Consumer Key. If successful, it generates a Request Token and Token Secret and returns them to the Consumer in the HTTP。服务商验证签名和使用者的Key,成功之后,生成RequestToken and Token Secret,以HTTP返回给用户。
- oauth_token:
- The Request Token.
- oauth_token_secret:
- The Token Secret.
- Additional parameters:
- Any additional parameters, as defined by the Service Provider.
3、Obtaining User Authorization
此时使用者还不能访问资源,需要用户验证用户名密码等。
1)、Consumer Directs the User to the Service Provider 使用者将用户导向到服务提供者,之后验证用户的合法性。
- oauth_token:
- OPTIONAL. The Request Token obtained in the previous step. The Service Provider MAY declare this parameter as REQUIRED, or accept requests to the User Authorization URL without it, in which case it will prompt the User to enter it manually.
- oauth_callback:
- OPTIONAL. The Consumer MAY specify a URL the Service Provider will use to redirect the User back to the Consumer when Obtaining User Authorization is complete.
- Additional parameters:
- Any additional parameters, as defined by the Service Provider.
2)、Service Provider Authenticates the User and Obtains Consent.服务提供者验证用户并获得用户的同意
3)、Service Provider Directs the User Back to the Consumer 将用户导向使用者。
3、Obtaining an Access Token 获取AccessToken
1)、Consumer Requests an Access Token
The Request Token and Token Secret MUST be exchanged for an Access Token and Token Secret. 使用上面获取的Request Token 和Token Secret 换取Access Token and Token Secret。
- oauth_consumer_key:
- The Consumer Key.
- oauth_token:
- The Request Token obtained previously.
- oauth_signature_method:
- The signature method the Consumer used to sign the request.
- oauth_signature:
- The signature as defined in Signing Requests.
- oauth_timestamp:
- As defined in Nonce and Timestamp.
- oauth_nonce:
- As defined in Nonce and Timestamp.
- oauth_version:
- OPTIONAL. If present, value MUST be 1.0 . Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present. Service Providers’ response to non-1.0 value is left undefined.
2)、Service Provider Grants an Access Token 授权Access Token。
4、Accessing Protected Resources
接下来就是获取相应的资源了。
三、Oauth2.0过程
关于Oauth2.0的认证过程可以参见:http://www.cnblogs.com/plxx/p/3961632.html
四、两个版本的区别
1、2.0的用户授权过程有2步,
A)引导用户到授权服务器,请求用户授权,用户授权后返回 授权码(Authorization Code)
B)客户端由授权码到授权服务器换取访问令牌(access token)
C)用访问令牌去访问得到授权的资源
1.0的授权分3步,
A)客户端到授权服务器请求一个授权令牌(request token&secret)
B)引导用户到授权服务器请求授权
C)用访问令牌到授权服务器换取访问令牌(access token&secret)
D)用访问令牌去访问得到授权的资源
2、1.0协议每个token都有一个加密,2.0则不需要。这样来看1.0似乎更加安全,但是2.0要求使用https协议,安全性也更高一筹。
3、2.0充分考虑了客户端的各种子态,因而提供了多种途径获取访问令牌
a)授权码
b)客户端私有证书
c)资源拥有者密码证书
d)刷新令牌
e)断言证书
1.0只有一个用户授权流程。
4、两个版本中的请求参数和token的内容有所改变。
Oauth1.0认证过程的更多相关文章
- OAuth2.0认证过程
本文以腾讯微博为例,详细介绍OAuth2.0的认证过程. 在使用腾讯微博平台提供的API前,您需要做以下两步工作: 成为开发者,并申请appkey和appsecret 授权获取accesstoken ...
- C# 网络编程之豆瓣OAuth2.0认证具体解释和遇到的各种问题及解决
近期在帮人弄一个豆瓣API应用,在豆瓣的OAuth2.0认证过程中遇到了各种问题,同一时候自己须要一个个的尝试与解决,终于完毕了豆瓣API的訪问.作者这里就不再吐槽豆瓣的认证文档了,毕 ...
- .net core 1.0 Web MVC 自定义认证过程
通过官方的介绍可知,若要本地开始部署搭建一个基于.net core 1.0的Web应用,需要下载dotnet SDK,或在Visual Studio IDE之上安装相关插件以布置开发环境.为了使开发环 ...
- C#搭建Oauth2.0认证流程以及代码示例
我认为对于一个普遍问题,必有对应的一个简洁优美的解决方案.当然这也许只是我的一厢情愿,因为根据宇宙法则,所有事物总归趋于混沌,而OAuth协议就是混沌中的产物,不管是1...0a还是2.,单看版本号就 ...
- 问题:OAuth1.0;结果:OAuth1.0协议
OAuth1.0协议 概要 OAuth提供了一种client代表资源的拥有者访问server的方法,也就是在资源拥有者不向第三方提供证书(通常是指用户名和密码)的情况下,允许第三方使用用户代理重定向访 ...
- .Net WebApi 实现OAuth2.0认证
现在多数公众平台提供的api都使用OAuth2.0认证模式,最近在搞Android方面的开发,身份认证和权限控制的各方面比较来说,使用OAuth认证的还是比较靠谱,OAuth2.0的协议可以参考htt ...
- 使用Owin中间件搭建OAuth2.0认证授权服务器
前言 这里主要总结下本人最近半个月关于搭建OAuth2.0服务器工作的经验.至于为何需要OAuth2.0.为何是Owin.什么是Owin等问题,不再赘述.我假定读者是使用Asp.Net,并需要搭建OA ...
- OAuth2.0认证和授权原理
什么是OAuth授权? 一.什么是OAuth协议 OAuth(开放授权)是一个开放标准. 允许第三方网站在用户授权的前提下访问在用户在服务商那里存储的各种信息. 而这种授权无需将用户提供用户名和密 ...
- hOAuth2.0认证和授权原理
原文地址: http://www.6zou.net/tech/what_is_oauth.html http://www.phpddt.com/%E4%BA%8C%E6%AC%A1%E5%BC%80% ...
随机推荐
- [转]IOS 学习笔记(8) 滚动视图(UIScrollView)的使用方法
下面介绍pageControl结合ScrollView实现连续滑动翻页的效果,ScrollView我们在应用开发中经常用到,以g这种翻页效果还是很好看的,如下图所示: 通过这个例子,我们重点学习UIS ...
- IMP-00008: unrecognized statement in the export file: string的问题分析
分类: Linux 上周需要将oracle10g中的某一个用户下的对象导入到oracle11g中去.用exp在10g的数据库服务器上导出的dump文件,再用imp在11g的数据库服务器上将dump文件 ...
- SIGAR - System Information Gatherer And Reporter
https://support.hyperic.com/display/SIGAR/Home 收藏一篇: http://www.cnitblog.com/houcy/archive/2012/11/2 ...
- hdu 3228 (最大流+二分)
题意:一共有N个城市,一些城市里有金矿,一些城市里有仓库,金矿和仓库都有一个容量,有M条边,每条边是双向的,有一个权值,求将所有金矿里的储量都运送到仓库中,所需要经过的道路中,使最大的权值最小 思路: ...
- [置顶] c++播放Flash文件
最近由于需要在程序中使用Flash播放,所以学习了下如何播放Flash,这里使用atl库中的CAxWindow来处理我们要播放的Flash!由于Flash的很多接口我们都不知道,所以可以参考前一篇文章 ...
- mac下配置cocos2d-x3.0
今天看到3.0的正式版公布了,就马上荡下来试试3.0,以下记录下环境变量配置过程 打开用户文件夹下.bash_profile文件,配置环境 1.首先配置下android sdk,我的是在opt文件夹下 ...
- HDU-4866-Shooting(函数式线段树)
Problem Description In the shooting game, the player can choose to stand in the position of [1, X] t ...
- PHP程序猿必须学习的第二课——站点安全问题预防
作为PHP程序猿.第一课我们学习了基本的语法.那么在熟悉基本的语法之后我们应该学些什么呢?我觉得是安全问题.安全问题基于一个站点宛如基石,一着不慎,意味着灾难性的事故. 这里主要就提三点最简单,也是最 ...
- [译]Stairway to Integration Services Level 9 - Control Flow Task Errors
介绍 在本文中,我们会实验 MaximumErrorCount和ForceExecutioResult 故障容差属性,并且还要学习Control Flow task errors, event han ...
- Light OJ 1104 Birthday Pardo(生日悖论)
ime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description Sometime ...