OIDC - at_hash 验证
OIDC - at_hash validation
我正在尝试从开放 ID 规范中获得一些关于 at_hash 定义的说明。
Access Token hash value. Its value is the base64url encoding of the
left-most half of the hash of the octets of the ASCII representation
of the access_token value, where the hash algorithm used is the hash
algorithm used in the alg Header Parameter of the ID Token's JOSE
Header. For instance, if the alg is RS256, hash the access_token value
with SHA-256, then take the left-most 128 bits and base64url encode
them. The at_hash value is a case sensitive string.
access_token 值的 ASCII 表示的八位字节哈希
这是我感到困惑的部分。
这是否意味着我们应该散列整个访问令牌
或
我们是否应该解码访问令牌并像 JTI 那样只对单个字段进行哈希处理?
我认为伪代码是:
getBase64UrlString(getLeftHalfOfArray(getSha256Bytes(getAsciiBytes(accessTokenJwtString))))
示例 C# 实现在这里:
在CreateHashClaimValue()
我正在尝试从开放 ID 规范中获得一些关于 at_hash 定义的说明。
Access Token hash value. Its value is the base64url encoding of the left-most half of the hash of the octets of the ASCII representation of the access_token value, where the hash algorithm used is the hash algorithm used in the alg Header Parameter of the ID Token's JOSE Header. For instance, if the alg is RS256, hash the access_token value with SHA-256, then take the left-most 128 bits and base64url encode them. The at_hash value is a case sensitive string.
access_token 值的 ASCII 表示的八位字节哈希
这是我感到困惑的部分。
这是否意味着我们应该散列整个访问令牌
或
我们是否应该解码访问令牌并像 JTI 那样只对单个字段进行哈希处理?
我认为伪代码是:
getBase64UrlString(getLeftHalfOfArray(getSha256Bytes(getAsciiBytes(accessTokenJwtString))))
示例 C# 实现在这里:
在CreateHashClaimValue()