单点登录:如登录了淘宝账号,就可免登录使用天猫、聚划算等应用

         

springcloud oauth2 token续签_客户端

 

 

*************************

名词解释:以jd使用微信登录为例

 

third party application:三方应用,jd

http service:http服务商,微信

resource owner:资源所有者,微信注册用户

user agent:用户代理,web端(用户使用浏览器使用jd)、app端(用户使用app应用使用jd)

authorization server:认证服务器,微信处理认证的服务器

resource server:资源服务器,微信相关数据,jd后端服务

 


 

               

springcloud oauth2 token续签_客户端_02

客户端向用户获取授权,用户同意授权后返回授权码;

客户端使用授权码向authorization server申请token,authorization server检验通过后返回token;

客户端使用token向resource server申请所需要的资源,resource server经authorization server检验通过后发放resource

 

说明:该模式流程完善,将token存储在后端,安全性较高

 

******************

密码模式:password

 

              

springcloud oauth2 token续签_客户端_03

用户使用密码向resource server申请token,resource server检验通过后发放token;

客户端使用token向resource server申请需要的资源,resource server通过authorization server检验通过后发放资源

 

说明:该模式使用密码认证,适用于高度信任的应用,安全性较授权码模式低

 

******************
简化模式:implicit

 

              

springcloud oauth2 token续签_微信_04

客户端向 authorization server 申请授权,authorization server验证通过后直接发放token;

客户端使用token向resource server申请获取resource,resource server通过authorization server验证通过后发放resource

 

说明:implicit模式直接向前端发放token,不安全,适用于安全性不高的场景

 

******************

客户端模式:client credentials

 

             

springcloud oauth2 token续签_客户端_05

客户端使用命令行向authorization server申请token,authorization server验证通过后发放token;

客户端使用命令行携带token向resource server申请resource,resource server经authorization server验证通过后发放resource

 

说明:该模式适用于没有前端的应用,不常用

 

******************

更新令牌

 

令牌发放时,发放两个令牌:访问令牌和更新令牌;

在令牌到期前,使用更新令牌请求更新令牌,避免重新认证登陆

 

更新令牌请求:

http://host:port/oauth/token?
grant_type=refresh_token&
client_id=Client_id&
client_scret=Client_scret&
refresh_token=Refresh_token

grant_type:认证类型

client_id:客户端id

client_scret:客户端scret

refresh_token:更新令牌