目录
第1章 OAuth2概述......................................................................1
1.1
1.2
OAuth 2 的定义 ·········································································.2 1.1.1 官方定义.................................................................................................................2 1.1.2 开放平台中的定义 .................................................................................................2 OAuth 2 的四种授权模式 ·····························································.3
1.2.1 隐式授权模式.........................................................................................................3
1.2.2 授权码授权模式 .....................................................................................................5
1.2.3 授信客户端密码模式 ...........................................................................................10
1.2.4 授信客户端模式 ...................................................................................................12
第2章 开放平台整体架构.............................................................15
2.1 2.2
2.3
2.4
功能架构 ···············································································.16 API 网关系统··········································································.18
2.2.1 API 整体架构 .......................................................................................................18
2.2.2 API 网关与授权系统的关系................................................................................19
控制台系统 ············································································.20 2.3.1 功能概述...............................................................................................................20
2.3.2 控制台系统与授权系统的关系 ...........................................................................20
服务市场 ···············································································.21
第3章 实战中的授权模式.............................................................22
3.1
3.2 3.3
授权码授权模式的应用 ·····························································.23
3.1.1 获取 code ..............................................................................................................23
3.1.2 获取授权信息.......................................................................................................27
3.1.3 刷新授权信息.......................................................................................................30
用户名密码授权码授权模式的应用 ··············································.31 授信客户端密码模式的应用 ·······················································.333.4
3.5
授信客户端模式的应用 ·····························································.34
3.4.1 标准授信客户端模式 ...........................................................................................34
3.4.2 自研应用...............................................................................................................35
3.4.3 自研授信客户端授权 ...........................................................................................35
插件化授权模式的应用 ·····························································.36 3.5.1 普通应用场景.......................................................................................................37 3.5.2 官方应用场景.......................................................................................................42
第4章 OpenID从理论到实战.......................................................48
4.1
4.2
4.3
4.4
4.5
OpenID 概述···········································································.49
4.1.1 OpenID 定义 .........................................................................................................49
4.1.2 OpenID 使用流程 .................................................................................................50
4.1.3 OpenID 与 OAuth 2 ..............................................................................................52
基于自增 ID 的 OpenID 方案·······················································.53
4.2.1 概述.......................................................................................................................53
4.2.2 基于单机模式下自增 ID 的实现方案 .................................................................54
4.2.3 基于雪花算法的 OpenID 生成方案 ....................................................................55
4.2.4 基于自增 ID 的 OpenID 生成方案总结 ..............................................................56
基于 Hash 算法的 OpenID 方案····················································.57
4.3.1 概述.......................................................................................................................57
4.3.2 Hash 算法简介......................................................................................................57
4.3.3 使用 Hash 函数计算 OpenID ...............................................................................58
4.3.4 基于 Hash 算法的 OpenID 方案总结 ..................................................................64
基于对称加密算法的 OpenID 方案 ···············································.64
4.4.1 概述.......................................................................................................................64
4.4.2 对称加密算法简介 ...............................................................................................64
4.4.3 基于对称加密算法的 OpenID 实践 ....................................................................66
4.4.4 基于对称加密算法的 OpenID 方案总结 ............................................................68
基于严格单调函数的 OpenID 方案 ···············································.69
4.5.1 相关概念...............................................................................................................69
4.5.2 基于严格单调函数的 OpenID 实践 ....................................................................70
4.5.3 基于严格单调函数的 OpenID 方案总结 ............................................................744.6
4.7 4.8
基于向量加法的 OpenID 方案 ·····················································.75
4.6.1 UUID 简介............................................................................................................75
4.6.2 基于向量加法的 OpenID 实践 ............................................................................76
4.6.3 矩阵乘法思路扩展 ...............................................................................................79
OpenID 小结················································