【发布时间】:2020-03-13 22:41:37
【问题描述】:
在 ASP.NET Core 3 应用程序中,我需要处理来自 id_token 和 access_token 的信息。
id_token 有会员信息,有时需要这些信息来制定政策。由于成员信息可能很大,将其作为access_token 的一部分是不可能的(令牌超过允许的最大大小)。
客户在x-id-token 标头中发送id_token,我正在寻找一种方法来提取它并使用其中的声明。
现在我已经配置了 JwtBearer 身份验证,它可以与 Authorization: Bearer access_token 标头无缝协作。
public void ConfigureServices(IServiceCollection services) {
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = $"https://{Configuration["auth:Domain"]}/";
options.Audience = Configuration["auth:Audience"];
});
...
}
【问题讨论】:
-
看起来您需要创建自定义身份验证。请看一个例子stackoverflow.com/questions/31464359/…
-
@BasilKosovan 感谢您为我指出解决方案。
标签: c# asp.net-core .net-core asp.net-core-mvc jwt