azure - Kentor/Owin/Azure AD 身份验证

标签 azure owin saml-2.0 kentor-authservices

我有一个 Web 表单应用程序,我正在尝试使用 SAML 2/Kentor/Owin 对 Azure AD 进行身份验证。我认为我已经配置好了,但是当我的登录页面发出以下命令时,我没有被重定向到登录页面。

                    HttpContext.Current.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/Login.aspx" });

这是我的startup.cs

private void ConfigureSAML2Authentication(IAppBuilder app) {
        var authServicesOptions = new KentorAuthServicesAuthenticationOptions(false)
        {
            SPOptions = new SPOptions
            {
                EntityId = new EntityId("https://login.microsoftonline.com/<tenant guid>/saml2")
            }
            },
            AuthenticationType = "KentorAuthServices",
            Caption = "ADFS - SAML2p",
        }; 

        authServicesOptions.IdentityProviders.Add(new IdentityProvider(
            new EntityId("https://sts.windows.net/<tenant guid>/"),
            authServicesOptions.SPOptions)
        {
            MetadataLocation = "https://login.microsoftonline.com/<tenant guid>/federationmetadata/2007-06/federationmetadata.xml",
            LoadMetadata = true,
        });

        app.UseKentorAuthServicesAuthentication(authServicesOptions);
    } 

据我所知,查看 Chrome 中的网络工具,根本没有发送任何身份验证请求。有谁能告诉我为什么吗?

最佳答案

AuthServices 中间件默认配置为被动,因此除非您指定提供程序,否则它不会自动响应身份验证质询。

当您发出质询时,您应该指定与设置中间件时使用的相同的 AuthenticationType。默认情况下,这是“KentorAuthServices”,但可以更改。

如果您更改挑战以包含类型,它应该会触发重定向:

HttpContext.Current.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/Login.aspx"}, "KentorAuthServices");

关于azure - Kentor/Owin/Azure AD 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47194409/

相关文章:

c# - Azure 移动服务中的同步冲突处理 : ad hoc vs sync handler

python - Azure Python 函数日期时间表达式

c# - 使用 C# 的 Azure 文本分析给出错误

c# - MVC 5 登录自定义数据库

passport.js - 如何为 loopbackJS 应用程序配置 SAML2 身份验证

java - 创建 SAML 断言并签署响应

azure - 以编程方式配置 Azure 缓存客户端

c# - Owin 中间件在服务器上导致 404

ASP.NET 身份数据库第一个自定义用户和角色

node.js - SAML/ADFS node.js 实现指南?