当我考虑为网站APIC进行认证时,我看到以下进程:
您的服务:
services.AddAuthentication().AddJwtBearer(o =>
{
o.TokenValidationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["secrets"]))
};
});
Next step all documentations I have seen talk about is: in order to generate the token, use some helper classes and pass the configurations such as secrets and issuer again.
This never made much sense to me. Since the AddJwtBearer
function has already taken in all configurations, isn t there a function as straightforward as httpContext.GenerateJwt(new Claims[]{})
that would generate the token? Why would we need to use so much boilerplate?
我自那以来就一直在寻找这样的职能。 NET 2.0。 我创立了一个新集团,以完成这项工作(我知道我所谈论的内容是可行和直截了当的)。 然而,NuGet公司不再工作。 NET 6.0。 我不想确定我的NuGet,而是想检查一下。 NET Core有一个清洁的解决方案,可以生成JWT信号。