我们的组织正在尝试在我们已经存在的asp.net mvc项目中实施Azure AD身份验证,我目前正在尝试使用示例项目进行研究
基础架构团队向我提供了一个xml文件,该文件从头开始
xmlns =“ urn:oasis:names:tc:SAML:2.0:metadata” entityID =“ https://sts.windows.net/XXXXXXXXXX” ID =“ YYYYYY”>
以及登录网址:https://login.microsoftonline.com/XXXXXXX/saml2,
注销网址
和天蓝色的IdentifierID。
我尝试在startup.auth.cs中使用这些值的这些代码
ADFSMetadata value =“ https://login.microsoftonline.com/XXXXXXXXX/FederationMetadata/2007-06/FederationMetadata.xml
Wtrealm“ value =” urn:Localhost
Wreply“ value =” https:// localhost:zzzz / ADFS_Implementation
基础架构团队还注意到了基本saml配置中的上述值,例如
Identifier(EntityID)是urn:localhost 回复网址是https:// localhost:zzzz / ADFS_Implementation
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = adfsMetadata,
Wreply = reply,
Notifications = new WsFederationAuthenticationNotifications()
{
SecurityTokenValidated = (notification) =>
{
ConfigureClaims(notification);
return Task.FromResult<object>(null);
}
},
TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
}
});
当我运行该应用程序时,我能够登录到Microsoft门户并进入我的组织adfs页面,但是当我输入凭据并单击登录时,它将引发此异常
IDX10501:签名验证失败。无法匹配密钥: 小子:“ Microsoft.IdentityModel.Xml.KeyInfo”, 令牌:“ Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken”。
堆栈跟踪
[SecurityTokenSignatureKeyNotFoundException:IDX10501:签名验证失败。无法匹配密钥:
小子:“ Microsoft.IdentityModel.Xml.KeyInfo”,
令牌:“ Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken”。]
C:\ agent2_work \ 56 \ s \ src \ Microsoft.IdentityModel.Tokens.Saml \ Saml2 \ Saml2SecurityTokenHandler.cs:385中的Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateSignature(字符串令牌,TokenValidationParametersvalidationParameters)
C:\ agent2_work \ 56 \ s \ src \ Microsoft.IdentityModel.Tokens.Saml \ Saml2 \ Saml2SecurityTokenHandler.cs:203中的Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateToken(字符串令牌,TokenValidationParametersvalidationParameters,SecurityToken&validatedToken)
Microsoft.Owin.Security.WsFederation.d__8.MoveNext()+2448
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+27
Microsoft.Owin.Security.WsFederation.d__8.MoveNext()+4095
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.Owin.Security.Infrastructure.d__31.MoveNext()+452
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.Owin.Security.Infrastructure.d__5.MoveNext()+217
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.Owin.Security.Infrastructure.d__5.MoveNext()+519
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.AspNet.Identity.Owin.d__5.MoveNext()+383
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.AspNet.Identity.Owin.d__5.MoveNext()+383
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.AspNet.Identity.Owin.d__5.MoveNext()+383
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__7.MoveNext()+179
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+64
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__12.MoveNext()+180
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)+69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)+64
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+389
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep步骤)+50
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值并已完成同步)+163
我看不到出什么问题了,谁能指出我正确的方向。