我正在尝试创建授权服务。 我有一个使用JWT承载认证的API服务
public void ConfigureServices(IServiceCollection services)
{
services.Configure<JwtIssuerOptions>(options =>
{
options.Issuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
options.Audience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)];
options.SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//...
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters
});
//...
}
使用返回令牌的操作。我想在主应用程序中使用此令牌进行身份验证。现在它使用cookies和:
HttpContext.Authentication.SignInAsync("Cookies", new ClaimsPrincipal(claimsIdentity)).
我如何将此令牌注入我的应用程序以及它需要什么配置?