我正在针对 azure b2c 对 asp.net mvc 应用程序进行身份验证,遵循 startup.cs 文件代码详细信息:
public void ConfigureAuth(IAppBuilder app)
{
IdentityModelEventSource.ShowPII = true;
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
// Generate the metadata address using the tenant and policy information
MetadataAddress = String.Format(Globals.WellKnownMetadata, Globals.Tenant, Globals.DefaultPolicy),
// These are standard OpenID Connect parameters, with values pulled from web.config
ClientId = Globals.ClientId,
RedirectUri = Globals.RedirectUri,
PostLogoutRedirectUri = Globals.RedirectUri,
// Specify the callbacks for each type of notifications
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = OnRedirectToIdentityProvider,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
AuthenticationFailed = OnAuthenticationFailed,
},
// Specify the claim type that specifies the Name property.
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
ValidateIssuer = false
},
// Specify the scope by appending all of the scopes requested into one string (separated by a blank space)
Scope = $"openid profile offline_access {Globals.ReadTasksScope} {Globals.WriteTasksScope}"
});
}
使用自定义策略时出现以下错误:IDX10501:签名验证失败。无法匹配键:孩子:'gL****************'。捕获的异常:''。令牌:typ":"JWT","alg":"RS256","kid":"gL******************"}. {"exp":1599625561," nbf":1599621961,"ver":"1.0","iss":.......}
我已验证此密钥和令牌与从https://jwt.ms获得的完全相同。当我使用自定义策略时,它唯一会抛出错误,如果我使用内置策略,它会按预期工作。
任何帮助这里缺少什么?
谢谢。