首页 > 解决方案 > 如何使用 Sustainsys 发起 SLO 请求

问题描述

尝试使用 Okta 获取 Single Log out 请求

我尝试在 Sustainsys 上使用示例代码,如下所示:

public async Task<IActionResult> Logout()
{
    await _signInManager.SignOutAsync();

    _logger.LogInformation("User logged out.");

    return SignOut(new AuthenticationProperties()
    {
        RedirectUri = "/Index"
    },
    Saml2Defaults.Scheme);
}

但这似乎并没有调用 Single Log Out。我只是被重定向到我的注销页面。从我读过的内容来看,它是受支持的,所以不确定我应该调用什么。在启动时,我加载了其中包含 SLO url 的元数据,因此它应该知道指向哪里。

Okta 需要一个证书,所以我在我的启动中添加了相关的 pfx 文件,如下所示:

        // Add Saml Athentication
        var authBuilder = services.AddAuthentication();
        authBuilder.AddSaml2(options =>
        {
            // SAML Okta options
            options.SPOptions.EntityId = new EntityId(Configuration["SAML:AudienceURI"]);

            // Set up redirect to SAML controller callback to handle log in after SAML Authentication (For Okta/IDP initiated log in)
            options.SPOptions.ReturnUrl = new Uri(Configuration["SAML:ReturnURL"]);

            // Scheme to handle the authentication
            options.SignInScheme = IdentityConstants.ExternalScheme;
            options.SignOutScheme = IdentityConstants.ApplicationScheme;

            // Set up Identity Provider
            var identityProvider = new IdentityProvider(
                new EntityId(Configuration["SAML:EntityID"]),
                options.SPOptions)
            {
                Binding = Saml2BindingType.HttpRedirect,
                LoadMetadata = true,
                MetadataLocation = Configuration["SAML:MetadataURL"],
                AllowUnsolicitedAuthnResponse = true
            };

            options.SPOptions.ServiceCertificates.Add(new X509Certificate2("Okta.pfx", ""));
            options.IdentityProviders.Add(identityProvider);
        });

有任何想法吗?我必须手动完成吗?如果是这样,任何指针都会很棒。

标签: asp.net-coresamlsaml-2.0sustainsys-saml2

解决方案


好的,一定错过了这个,但答案是重定向到 /Saml2/Logout

这仍然不起作用,因为不存在注销所需的声明,但此步骤可能对某人有所帮助。


推荐阅读