【问题标题】:Kentor/Owin/Azure AD AuthenticationKentor/Owin/Azure AD 身份验证
【发布时间】:2017-11-09 05:19:47
【问题描述】:

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

【问题讨论】:

    标签: azure owin saml-2.0 kentor-authservices


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 这确实有效。您说默认情况下它是被动的 - 有没有办法更改配置,以便我可以在不指定名称的情况下触发挑战?我有几种可能的身份验证配置(尽管为任何给定实例只配置了一种),并且没有添加一些额外的处理,我不知道具体是在运行时配置了哪一种。
    • 并回答我自己,我发现 AuthenticationMode = AuthenticationMode.Active!感谢您的帮助。
    猜你喜欢
    • 2019-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 2019-10-15
    • 1970-01-01
    • 2022-07-22
    相关资源
    最近更新 更多