代码之家  ›  专栏  ›  技术社区  ›  Johan Kronberg

在Web窗体项目中发生质询时,不重定向到SingleSignOnService位置

  •  0
  • Johan Kronberg  · 技术社区  · 7 年前

    我已经接管了一个项目,一些软件包升级是其他事情所必需的,所以我从这些工作的地方开始。。。

    <package id="Kentor.AuthServices" version="0.18.0" targetFramework="net452" />
    <package id="Kentor.AuthServices.Owin" version="0.18.0" targetFramework="net452" />
    <package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net452" />
    

    <package id="Sustainsys.Saml2" version="2.2.0" targetFramework="net472" />
    <package id="Sustainsys.Saml2.Owin" version="2.2.0" targetFramework="net472" />
    <package id="Microsoft.Owin" version="4.0.0" targetFramework="net472" />
    <package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0" targetFramework="net472" />
    <package id="Microsoft.Owin.Security" version="4.0.0" targetFramework="net472" />
    <package id="Microsoft.Owin.Security.Cookies" version="4.0.0" targetFramework="net472" />
    

    我遵循了迁移指南,但在我的Web表单项目中出现问题时,未能重定向到SingleSignOnService位置。

    My Web.config具有以下结构。。。

    <sustainsys.saml2 entityId="https://demo.local/AuthServices"
            returnUrl="https://demo.local"
            publicOrigin="https://demo.local"
            modulePath="/AuthServices">
        <serviceCertificates>
            <add fileName="~/somename.pfx"
                use="Signing" />
        </serviceCertificates>
        <identityProviders>
            <add entityId="My-IDP"
                allowUnsolicitedAuthnResponse="true"
                loadMetadata="true"
                metadataLocation="https://some-saml2-idp.com/metadata" />
        </identityProviders>
    </sustainsys.saml2>
    

    var defaultSignInAsAuthType = "Cookies";
    
    app.SetDefaultSignInAsAuthenticationType(defaultSignInAsAuthType);
    
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = defaultSignInAsAuthType,
        ReturnUrlParameter  = "returnUrl",
        LoginPath = new PathString("/login"),
        LogoutPath = new PathString("/logout")
    });
    
    var saml2Options = new Saml2AuthenticationOptions(true);
    app.UseSaml2Authentication(saml2Options);
    app.UseStageMarker(PipelineStage.Authenticate);
    
    AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name;
    

    我尝试在路径映射中触发一个挑战。。。

    ctx.Authentication.Challenge(new AuthenticationProperties()
    {
        RedirectUri = "https://demo.local"
    });
    

    我的问题是,我是否升级了Owin包太多,是否有人有一些故障排除提示?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Anders Abel    7 年前

    主动/被动的默认设置已更改。以前,中间件在默认情况下是活动的,这意味着它监听任何消息 Challenge 呼叫现在它是被动的,所以你必须使用 重载,指定身份验证方案并将其设置为“Saml2”。

    更改的原因是为了更好地遵循外部身份验证中间件的最佳实践。

    推荐文章