oAuth 2.0存储设计

编号:OAPI-DESIGN-004
作者:刘海龙
微博:[http://weibo.com/liuhailong2008]
博客:[http://blog.csdn.net/stationxp]

说明:

具体的存储形式还没有认证考虑,先按都存数据库考虑。token类的,查询次数多,redis应该更合适。
优化没有仔细考虑,如果确认放数据库,尽量保证数据创建后只读,减少写操作,横向分表,过期的业务数据搬到历史库。等等。
安全考虑,token等最好md5后再存,不存原文。client_id有必要吗?
先确认格式,具体做法以后再考虑。

注册

用户注册

oauth_user(user_id,user_name,password,corp_name,contact,addr,tel,mobile,fax,website,email,status,timestamp).
oauth_resource_owner(ro_id,ro_name,contact,addr,tel,mobile,email,fax,status,timestamp).

客户端注册

客户端编号(client id)。
所属用户。
重定向 URI。
客户端类型。
应用名称、网址、描述、Logo 图片、接受法律条款等。

oauth_client(client_id,user_id,redirect_uri,client_secret,security_env,client_type,client_name,client_website,client_desc,logo_url,law_terms,status,timestamp).
security_env :1-机密客户端,2-公开客户端;
client_type :1-Web应用,2-浏览器应用,3-本地应用。

授权

权限定义

oauth_scope(scope,resource,memo,version,timestamp).

授权申请

oauth_apply(apply_id,client_id,scope_list,apply_time,status,timestamp).

授权许可

oauth_grant(grant_code,apply_id,client_id,scope_list,approve_time).

授权码auth code

授权码用来换取access token,有效期一般不超过10分钟,只可以用一次。

不需要持久化保存。
保存在redis服务器上,key为auth_code,value为{client_id,redirect_uri}。

认证

oauth_token(access_token,refresh_token,scope_list,resource_list,client_id,redirect_uri,expires_in,create_time,status,timestamp).
status: 1-有效,2-过期

日志

oauth_log(log_id,from_uri,invoked_resource,access_token,response_code,response_msg,timestamp)

暂时先这样,对照协议再过一遍,有问题再改。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值