【发布时间】:2021-11-19 18:23:20
【问题描述】:
我正在使用 .Net Core 3.1 授权框架来制作 Openid 流,并将我的授权重定向到第三方提供商,这是我的配置:
services.AddAuthorization(cfg =>
{
cfg.AddPolicy("MyPolicy", cfgPolicy =>
{
cfgPolicy.AddRequirements().RequireAuthenticatedUser();
cfgPolicy.AddAuthenticationSchemes(OpenIdConnectDefaults.AuthenticationScheme);
});
}).AddAuthentication(cfg =>
{
cfg.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
cfg.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(cfg =>
{
cfg.ClientId = authenticationConfig.ClientId;
cfg.ClientSecret = authenticationConfig.ClientSecret;
cfg.ResponseType = "code";
cfg.CallbackPath = "/login/callback";
cfg.GetClaimsFromUserInfoEndpoint = true;
cfg.Scope.Clear();
cfg.Scope.Add("openid");
cfg.Configuration = new OpenIdConnectConfiguration
{
AuthorizationEndpoint = authenticationConfig.UrlSts + "authorize",
TokenEndpoint = "https://interal.io/api/oauth/token",
UserInfoEndpoint = "https://interal.io/api/oauth/token_info"
};
});
但我在类 OpenIdConnectProtocolValidator 中的 ValidationHash 步骤中遇到错误。我的 at_hash 声明以不同的方式生成,不等于此处指定:https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation。
如何在 OpenIdConnectProtocolValidator 类中自定义 ValidateHash 方法??
【问题讨论】:
标签: asp.net-core openid-connect openid asp.net-authorization