8

访问令牌(access token)和刷新令牌(refresh_token )

 3 years ago
source link: https://www.jianshu.com/p/bdba30dd1ec0
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

访问令牌(access token)和刷新令牌(refresh_token )

0.1412019.07.15 18:54:15字数 256阅读 2,962

1、token化的协议过程

image

2、当用户登录的时候,生成access_token和refresh_token,并返回给APP。
当access_token失效时,APP使用refresh_token来请求刷新token。
如果refresh_token过期,需要用户重新登录,。也就是说,用户每一次登陆的时候refresh_token都会重新更改

3、token验证

image.png

4、刷新token

image.png
  • 客户端缓存用户名和密码,容易受到黑客攻击,如果使用了token机制,就算黑客盗取了用户的access_token与refresh_token,只需重新登录,就可令原来的token失效。
  • 如果访问令牌受到劫持,由于它的存在是短时间的,所以对访问令牌的滥用是控制在一定范围内的。
    如果刷新令牌被劫持,基本上无害的,攻击者需要得到 client_id,secrect_id (通常存储在服务器上),再加上刷新令牌才可以进行操作。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK