无法使用 Sustainsys 的 Saml2 注销

Art*_*ros 2 saml saml-2.0 asp.net-core sustainsys-saml2

这应该将我的应用程序重定向到我的 AdFs 注销页面,然后将我重定向回我的应用程序。然而,它只是将我重定向到我的路线“/logout”。查看我的 ADFS 服务器上的日志,没有任何反应。

        [AllowAnonymous]
        [HttpGet]
        [Route("api/logout")]
        public async Task<IActionResult> Logout()
        {
            return SignOut(new AuthenticationProperties()
            {
                RedirectUri = "/logout"
            },
            Saml2Defaults.Scheme);
        }

Run Code Online (Sandbox Code Playgroud)

登录工作正常。我什至尝试过同样的方法,但不起作用。这里,ReturnUrl 方法从 HttpContext.Response.Header 获取位置。当我尝试注销时,该位置始终为空。

        [AllowAnonymous]
        [HttpGet]
        [Route("api/login")]
        public async Task<string> LoginAdfs()
        {

            string redirectUri =  _appSettings.Saml.SpEntityId;

            await HttpContext.ChallengeAsync(new AuthenticationProperties
            {
                RedirectUri = string.Concat(redirectUri, "/autenticado")
            });
            return ReturnUrl();
        }
Run Code Online (Sandbox Code Playgroud)

知道会发生什么吗?

更新 21/11/2019

结果 Saml2Handler 根本就没有尝试将请求发送到服务器。我在输出窗口上收到这些消息:

Sustainsys.Saml2.AspNetCore2.Saml2Handler: Debug: Initiating logout, checking requirements for federated logout
  Issuer of LogoutNameIdentifier claim (should be Idp entity id): 
  Issuer is a known Idp: False
  Session index claim (should have a value): 
  Idp has SingleLogoutServiceUrl: 
  There is a signingCertificate in SPOptions: True
  Idp configured to DisableOutboundLogoutRequests (should be false): 
Sustainsys.Saml2.AspNetCore2.Saml2Handler: Information: Federated logout not possible, redirecting to post-logout
Run Code Online (Sandbox Code Playgroud)

这是我的启动配置,我不明白这里有什么问题:

            ServiceCertificate se = new ServiceCertificate()
            {
                Certificate = new X509Certificate2(SpCert, "",X509KeyStorageFlags.MachineKeySet),
                Use = CertificateUse.Signing
            };

            SPOptions sp = new SPOptions
            {
                AuthenticateRequestSigningBehavior = SigningBehavior.Never,
                EntityId = new EntityId(SpEntityId),
                ReturnUrl = new Uri("/login"),
                NameIdPolicy = new Sustainsys.Saml2.Saml2P.Saml2NameIdPolicy(null, Sustainsys.Saml2.Saml2P.NameIdFormat.Unspecified),

            };
            sp.ServiceCertificates.Add(se);

            IdentityProvider idp = new IdentityProvider(new EntityId(appSettings.Saml.EntityId), sp);
            idp.Binding = Saml2BindingType.HttpPost;
            idp.AllowUnsolicitedAuthnResponse = true;
            //idp.WantAuthnRequestsSigned = true;
            idp.SingleSignOnServiceUrl = new Uri("/login");
            //idp.LoadMetadata = true;
            idp.SigningKeys.AddConfiguredKey(new X509Certificate2(IdpCert));
            idp.MetadataLocation = theMetadata;
            idp.DisableOutboundLogoutRequests = true;

Run Code Online (Sandbox Code Playgroud)

And*_*bel 5

为了使注销正常工作,两个特殊声明“LogoutNameIdentifier”和“SessionIndex”(全名需要http://Sustainsys.se/Saml2/LogoutNameIdentifier出现http://Sustainsys.se/Saml2/SessionIndex在用户身上。它们携带有关 Saml2 库需要能够执行注销的当前会话的信息。

现在我看不到你的整个启动,所以我无法理解你的应用程序的流程。但这些声明应该出现在库返回的身份中 - 可能存储在外部 cookie 中(如果您使用的是 asp.net 身份)。当您的应用程序设置应用程序 cookie 时,这两个声明必须转移到会话身份。

此外,您实际上已禁用出站注销DisableOutboundLogoutRequests。但这不是这里的主要问题,因为您的日志表明所需的声明不存在。


归档时间:

查看次数:

4367 次

最近记录:

2 年,9 月 前