没有合适的资源?快使用搜索试试~ 我知道了~
JWT handbook JWT手册
1星 需积分: 12 38 下载量 82 浏览量
2018-06-26
17:18:07
上传
评论 1
收藏 1.35MB PDF 举报
温馨提示
An introduction to the wonders of JSON Web Tokens and associated technologies.
资源推荐
资源详情
资源评论
The JWT Handbook
Sebastián E. Peyrott, Auth0 Inc.
Version 0.9.2, 2016
Abstract
An introduction to the wonders of JSON Web Tokens and associated technologies.
Contents
Special Thanks 4
1 Introduction 5
1.1 What is a JSON Web Token? . . . . . . . . . . . . . . . . . . . . 5
1.2 What problem does it solve? . . . . . . . . . . . . . . . . . . . . 6
1.3 A little bit of history . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Practical Applications 8
2.1 Client-side/Stateless Sessions . . . . . . . . . . . . . . . . . . . . 8
2.1.1 Security Considerations . . . . . . . . . . . . . . . . . . . 9
2.1.1.1 Signature Stripping . . . . . . . . . . . . . . . . 9
2.1.1.2 Cross-Site Request Forgery (CSRF) . . . . . . . 10
2.1.1.3 Cross-Site Scripting (XSS) . . . . . . . . . . . . 11
2.1.2 Are Client-Side Sessions Useful? . . . . . . . . . . . . . . 13
2.1.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Federated Identity . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.1 Access and Refresh Tokens . . . . . . . . . . . . . . . . . 17
2.2.2 JWTs and OAuth2 . . . . . . . . . . . . . . . . . . . . . . 19
2.2.3 JWTs and OpenID Connect . . . . . . . . . . . . . . . . . 19
2.2.3.1 OpenID Connect Flows and JWTs . . . . . . . . 19
2.2.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.4.1 Setting up Auth0 Lock for Node.js Applications 20
3 JSON Web Tokens in Detail 23
3.1 The Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 The Payload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.1 Registered Claims . . . . . . . . . . . . . . . . . . . . . . 25
3.2.2 Public and Private Claims . . . . . . . . . . . . . . . . . . 26
3.3 Unsecured JWTs . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4 Creating an Unsecured JWT . . . . . . . . . . . . . . . . . . . . 28
3.4.1 Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5 Parsing an Unsecured JWT . . . . . . . . . . . . . . . . . . . . . 29
3.5.1 Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . 29
1
4 JSON Web Signatures 31
4.1 Structure of a Signed JWT . . . . . . . . . . . . . . . . . . . . . 32
4.1.1 Algorithm Overview for Compact Serialization . . . . . . 33
4.1.2 Practical Aspects of Signing Algorithms . . . . . . . . . . 34
4.1.3 JWS Header Claims . . . . . . . . . . . . . . . . . . . . . 37
4.1.4 JWS JSON Serialization . . . . . . . . . . . . . . . . . . . 38
4.1.4.1 Flattened JWS JSON Serialization . . . . . . . . 39
4.2 Signing and Validating Tokens . . . . . . . . . . . . . . . . . . . 39
4.2.1 HS256: HMAC + SHA-256 . . . . . . . . . . . . . . . . . 40
4.2.2 RS256: RSASSA + SHA256 . . . . . . . . . . . . . . . . . 40
4.2.3 ES256: ECDSA using P-256 and SHA-256 . . . . . . . . . 41
5 JSON Web Encryption (JWE) 43
5.1 Structure of an Encrypted JWT . . . . . . . . . . . . . . . . . . 46
5.1.1 Key Encryption Algorithms . . . . . . . . . . . . . . . . . 47
5.1.1.1 Key Management Modes . . . . . . . . . . . . . 48
5.1.1.2
Content Encryption Key (CEK) and JWE En-
cryption Key . . . . . . . . . . . . . . . . . . . . 50
5.1.2 Content Encryption Algorithms . . . . . . . . . . . . . . . 50
5.1.3 The Header . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1.4 Algorithm Overview for Compact Serialization . . . . . . 51
5.1.5 JWE JSON Serialization . . . . . . . . . . . . . . . . . . . 52
5.1.5.1 Flattened JWE JSON Serialization . . . . . . . 54
5.2 Encrypting and Decrypting Tokens . . . . . . . . . . . . . . . . . 55
5.2.1 Introduction: Managing Keys with node-jose . . . . . . . 55
5.2.2 AES-128 Key Wrap (Key) + AES-128 GCM (Content) . 56
5.2.3
RSAES-OAEP (Key) + AES-128 CBC + SHA-256 (Content)
57
5.2.4 ECDH-ES P-256 (Key) + AES-128 GCM (Content) . . . 58
5.2.5
Nested JWT: ECDSA using P-256 and SHA-256 (Signa-
ture) + RSAES-OAEP (Encrypted Key) + AES-128 CBC
+ SHA-256 (Encrypted Content) . . . . . . . . . . . . . . 58
5.2.6 Decryption . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6 JSON Web Keys (JWK) 61
6.1 Structure of a JSON Web Key . . . . . . . . . . . . . . . . . . . 62
6.1.1 JSON Web Key Set . . . . . . . . . . . . . . . . . . . . . 63
7 JSON Web Algorithms 64
7.1 General Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.1.1 Base64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.1.1.1 Base64-URL . . . . . . . . . . . . . . . . . . . . 66
7.1.1.2 Sample Code . . . . . . . . . . . . . . . . . . . . 67
7.1.2 SHA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.2 Signing Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.2.1 HMAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.2.1.1 HMAC + SHA256 (HS256) . . . . . . . . . . . . 75
2
剩余76页未读,继续阅读
资源评论
- 大浪随波2020-10-10版本较旧,积分要的太高
Vivi9565
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C# winform置托盘图标并闪烁演示源码.zip
- 打包和分发Rust工具.pdf
- SQL中的CREATE LOGFILE GROUP 语句.pdf
- C语言-leetcode题解之第172题阶乘后的零.zip
- C语言-leetcode题解之第171题Excel列表序号.zip
- C语言-leetcode题解之第169题多数元素.zip
- ocr-图像识别资源ocr-图像识别资源
- 图像识别:基于Resnet50 + VGG16模型融合的人体细胞癌症分类模型实现-图像识别资源
- C语言-leetcode题解之第168题Excel列表名称.zip
- C语言-leetcode题解之第167题两数之和II-输入有序数组.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功