IDX21323:RequireNonce 是"[PII 已隐藏]"。OpenIdConnectProtocolValidationContext.Nonce was null



我知道有几个线程在相同的,但没有一个解决方案适用于我,有任何解决方案。奇怪的是,当我在IE中运行应用程序时,它会像在Edge中一样工作,我遇到了这个问题

IDX21323: RequireNonce是'[PII是隐藏的]'。OpenIdConnectProtocolValidationContext。Nonce为零,OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce不为空。的Nonce不能被验证。如果不需要检查nonce,请设置OpenIdConnectProtocolValidator。要求一次为"false"。注意如果如果找到'nonce',它将被求值。

代码

public class Startup
{
// The Client ID is used by the application to uniquely identify itself to Azure AD.
string clientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"];
// RedirectUri is the URL where the user will be redirected to after they sign in.
string redirectUri = System.Configuration.ConfigurationManager.AppSettings["RedirectUri"];
// Tenant is the tenant ID (e.g. contoso.onmicrosoft.com, or 'common' for multi-tenant)
static string tenant = System.Configuration.ConfigurationManager.AppSettings["Tenant"];
// Authority is the URL for authority, composed by Microsoft identity platform endpoint and the tenant name (e.g. https://login.microsoftonline.com/contoso.onmicrosoft.com/v2.0)
string authority = String.Format(System.Globalization.CultureInfo.InvariantCulture, System.Configuration.ConfigurationManager.AppSettings["Authority"], tenant);
/// <summary>
/// Configure OWIN to use OpenIdConnect 
/// </summary>
/// <param name="app"></param>
public void Configuration(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
// Sets the ClientId, authority, RedirectUri as obtained from web.config
ClientId = clientId,
Authority = authority,
RedirectUri = redirectUri,
// PostLogoutRedirectUri is the page that users will be redirected to after sign-out. In this case, it is using the home page
PostLogoutRedirectUri = redirectUri,
Scope = OpenIdConnectScope.OpenIdProfile,
// ResponseType is set to request the code id_token - which contains basic information about the signed-in user
ResponseType = OpenIdConnectResponseType.CodeIdToken,
// OpenIdConnectAuthenticationNotifications configures OWIN to send notification of failed authentications to OnAuthenticationFailed method
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = OnAuthenticationFailed
}
}
);
}
/// <summary>
/// Handle failed authentication requests by redirecting the user to the home page with an error in the query string
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
private Task OnAuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> context)
{
context.HandleResponse();
context.Response.Redirect("/?errormessage=" + context.Exception.Message);
return Task.FromResult(0);
}
}

我累了可用的选项,但没有工作,是否有任何可能的解决方案

指向OpenIdConnectProtocolValidationContext。Nonce为null

请尝试更新您的Microsoft.Owin.Security.OpenIdConnect包以匹配其他Owin包的版本号,如本相关线程中所讨论的。

Microsoft.Owin [4.1.1]
Microsoft.Owin.Security [4.1.1]
Microsoft.Owin.Security.Cookies [4.1.1]

如果您使用的是Google Chrome,请确保您也已更新到最新版本的Chrome,或者在其他浏览器中进行测试。(本指南讨论了导致此错误的Chrome问题。)

相关内容

  • 没有找到相关文章

最新更新