【发布时间】:2021-04-12 11:21:24
【问题描述】:
我有这个问题,我通过这种方式使用 EncryptingCredentials 在 .net 核心中创建了一个 JWE:
var key = Encoding.ASCII.GetBytes(Configuration["Core:JwtSecret"]);
var encryptionkey = Encoding.ASCII.GetBytes(Configuration["Core:JwtEncrype"]);
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = subject,
Expires = DateTime.UtcNow.AddDays(Convert.ToInt32(Host.Config["Core:JwtDays"])),
SigningCredentials =
new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature),
EncryptingCredentials =
new EncryptingCredentials(new SymmetricSecurityKey(encryptionkey), SecurityAlgorithms.Aes128KW, SecurityAlgorithms.Aes128CbcHmacSha256)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
user.Token = tokenHandler.WriteToken(token);
如何使用 Angular 读取令牌的数据?
【问题讨论】:
-
不,这只是在没有加密密钥和 EncryptingCredentials 的情况下工作。
标签: c# angular .net-core jwt jwe