没有合适的资源?快使用搜索试试~ 我知道了~
首页JWT handbook JWT手册
JWT handbook JWT手册
1星 需积分: 12 38 下载量 11 浏览量
更新于2023-03-16
评论 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页未读,继续阅读
Vivi9565
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1