2

我有一个 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 中的网络工具,根本没有发送任何身份验证请求。有人能告诉我为什么吗?

4

1 回答 1

2

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

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

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

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

于 2017-11-09T14:40:56.453 回答