Asp.net mvc 4 无法使用azuread联合身份验证进行身份验证

Asp.net mvc 4 无法使用azuread联合身份验证进行身份验证,asp.net-mvc-4,azure-active-directory,adfs,ws-federation,Asp.net Mvc 4,Azure Active Directory,Adfs,Ws Federation,我们的组织正试图在我们已经存在的asp.net mvc项目中实现Azure AD身份验证,目前我正在尝试使用示例项目进行研究 基础设施团队为我提供了一个xml文件,该文件从以下几行开始 xmlns=“urn:oasis:names:tc:SAML:2.0:metadata”entityID=”https://sts.windows.net/XXXXXXXXXX“ID=”yyyyy“> 和登录url:, 注销url 还有天蓝识别号 我试图在startup.auth.cs中使用这些值的代码 ADFS

我们的组织正试图在我们已经存在的asp.net mvc项目中实现Azure AD身份验证,目前我正在尝试使用示例项目进行研究

基础设施团队为我提供了一个xml文件,该文件从以下几行开始 xmlns=“urn:oasis:names:tc:SAML:2.0:metadata”entityID=”https://sts.windows.net/XXXXXXXXXX“ID=”yyyyy“>
和登录url:, 注销url
还有天蓝识别号

我试图在startup.auth.cs中使用这些值的代码
ADFSMetadata值=”https://login.microsoftonline.com/XXXXXXXXX/FederationMetadata/2007-06/FederationMetadata.xml
Wtrealm“value=“urn:Localhost
Wreply“值=”https://localhost:zzzz/ADFS_Implementation

基础架构团队还注意到了基本saml配置中的上述值,如

标识符(EntityID)为urn:localhost 回复url为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
                }
            });
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(新的CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
新WsFederationAuthenticationOptions
{
Wtrealm=realm,
MetadataAddress=adfsMetadata,
Wreply=答复,
通知=新建WsFederationAuthenticationNotifications()
{
SecurityTokenValidated=(通知)=>
{
配置索赔(通知);
返回Task.FromResult(空);
}
},
TokenValidationParameters=新的TokenValidationParameters
{
ValidateAudience=false
}
});
当我运行应用程序时,我可以登录到microsoft portal和我的组织adfs页面,但当我输入凭据并单击登录时,它会引发此异常

IDX10501:签名验证失败。无法匹配密钥: kid:'Microsoft.IdentityModel.Xml.KeyInfo', 令牌:“Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken”

堆栈跟踪
[SecurityTokenSignatureKeyNotFoundException:IDX10501:签名验证失败。无法匹配密钥: kid:'Microsoft.IdentityModel.Xml.KeyInfo', 令牌:“Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken”。] C:\agent2\u work\56\s\src\Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateSignature(字符串令牌,令牌验证参数validationParameters)中的Microsoft.IdentityModel.Tokens.Saml\Saml2\Saml2SecurityTokenHandler.cs:385 C:\agent2\u work\56\s\src\Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateToken(字符串令牌、令牌验证参数验证参数、安全令牌和验证令牌)中的Microsoft.IdentityModel.Tokens.Saml\Saml2\Saml2SecurityTokenHandler.cs:203 Microsoft.Owin.Security.WsFederation.d_u8.MoveNext()+2448 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+27 Microsoft.Owin.Security.WsFederation.d_u8.MoveNext()+4095 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.Owin.Security.Infrastructure.d_u31.MoveNext()+452 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.Owin.Security.Infrastructure.d_u5.MoveNext()+217 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.Owin.Security.Infrastructure.d_u5.MoveNext()+519 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.AspNet.Identity.Owin.d_u5.MoveNext()+383 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.AspNet.Identity.Owin.d_u5.MoveNext()+383 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.AspNet.Identity.Owin.d_u5.MoveNext()+383 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d_u7.MoveNext()+179 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务任务)+102 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)+64 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d_u12.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


我看不出哪里出了问题,有人能给我指出正确的方向吗。

请检查下面的两个链接,看看是否有帮助,