Introduction
JOSE is a framework intended to provide a method to securely transfer claims (such as authorization information) between parties. The JOSE framework provides a collection of specifications to serve this purpose. A JSON Web Token (JWT) contains claims that can be used to allow a system to apply access control to resources it owns. One potential use case of the JWT is as the means of authentication and authorization for a system that exposes resources through an OAuth 2.0 model.
JOSE
ID Token
标头声明
声明 | 格式 | 说明 |
---|---|---|
typ | String | 指示令牌是 JWT |
alg | String | 指示用于对令牌签名的算法。 示例:RS256 |
kid | String | 指定用于对此令牌的签名进行验证的公钥的指纹。 在 v1.0 和 v2.0 令牌中已发出。 |
x5t | String | 功能与 kid x5t |
有效负载声明
声明 | 格式 | 说明 |
---|---|---|
aud | String | 标识令牌的目标接收方。 在 id_tokens 中,受众是在 Azure 门户中分配给应用的应用程序 ID。 应验证此值。 如果令牌无法与应用的应用程序 ID 匹配,则应拒绝。 |
iss | String | 标识证书颁发者,或构造并返回令牌的“授权服务器”。 还标识在其中进行用户身份验证的 Azure AD 租户。 如果令牌由 v2.0 终结点颁发,则 URI 将以 /v2.0 结尾。 表示用户是来自 Microsoft 帐户的使用者用户的 GUID 为 9188040d-6c67-4c5b-b112-36a304b66dad。 应用应该使用声明的 GUID 部分限制可登录应用的租户集(如果适用)。 |
iat | Number | “Issued At” 表示针对此令牌进行身份验证的时间。 |
nbf | Number | nbf |
exp | Number | exp |
c_hash | String | 仅当 ID 令牌随 OAuth 2.0 授权代码一起颁发时,代码哈希才包含在 ID 令牌中。 它可用于验证授权代码的真实性。 若要了解如何执行此验证,请参阅 OpenID Connect 规范。 |
at_hash | String | 仅当 ID 令牌颁发自 /authorize /token |
preferred_username | String | 表示用户的主用户名。 可以是电子邮件地址、电话号码或未指定格式的一般用户名。 其值是可变的,可能随时改变。 由于此值可更改,因此不得用于做出授权决策。 需要 profile |
email | String | 对于具有电子邮件地址的来宾帐户,默认情况下会提供 email |
name | String | 此 name profile |
nonce | String | nonce /authorize |
sub | String | 令牌针对其断言信息的主体,例如应用的用户。 此值固定不变,无法重新分配或重复使用。 使用者是成对标识符 - 它对特定应用程序 ID 是唯一的。 如果单个用户使用两个不同的客户端 ID 登录到两个不同的应用,这些应用将收到两个不同的使用者声明值。 这不一定是所需的,具体取决于体系结构和隐私要求。 |
JWA
…
JWE
…
JWK
…
JWS
…
JWT
…
Programming
Golang
https://github.com/salrashid123/golang-jwt-pkcs11
https://github.com/salrashid123/golang-jwt-yubikey
https://github.com/salrashid123/golang-jwt-tpm
https://github.com/salrashid123/golang-jwt-pqc
https://github.com/salrashid123/golang-jwt-tink
https://github.com/salrashid123/golang-jwt-signer
Reference
- https://jose.readthedocs.io/en/latest/ - Javascript Object Signing and Encryption (JOSE)
- https://docs.microsoft.com/zh-cn/azure/active-directory/develop/id-tokens - Microsoft 标识平台 ID 令牌