Kentor / Owin / Azure AD身份验证

时间:2017-11-09 05:19:48

标签: 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中查看网络工具,根本没有发送身份验证请求。有人能告诉我为什么吗?

1 个答案:

答案 0 :(得分:2)

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

发出质询时,应指定在设置中间件时使用的相同AuthenticationType。默认情况下,这是&#34; KentorAuthServices&#34;但可以改变。

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

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