简体   繁体   English

如何从 SiteMinder session 注销 Pivotal Cloud Foundry 托管的 JSP/Servlet 应用程序?

[英]How to do a logout from SiteMinder session for a Pivotal Cloud Foundry hosted JSP/Servlet application?

I am having a JSP/Servlet based application running on Pivotal Cloud Foundary and using Siteminder for authentication.我有一个基于 JSP/Servlet 的应用程序在 Pivotal Cloud Foundary 上运行并使用 Siteminder 进行身份验证。

The logout we implemented but is unsuccessful currentnly includes我们实施但当前不成功的注销包括

  • clearing of request.getSession().invalidate()清除 request.getSession().invalidate()
  • followed by clearing of cookiesn (request.getCookies followed by setting MaxAge of all cookies to 0)然后清除 cookiesn(request.getCookies 然后将所有 cookies 的 MaxAge 设置为 0)
  • followed by calling of the siteminder provided /logout url in new popup window然后在新弹出窗口 window 中调用提供的站点管理员 /logout url
  • followed by window.location as PCF Logout for logout from the PCF application.后跟 window.location 作为 PCF 注销以从 PCF 应用程序注销。

With above steps the logout is not successful.通过上述步骤,注销不成功。 However if I do the Shift+Cntrl+Del and delete the cookies --> then the logout works successful.但是,如果我执行 Shift+Cntrl+Del 并删除 cookies --> 则注销成功。 So programmatically I want to achieve the same behavior using Servlet and JSP.因此,我想以编程方式使用 Servlet 和 JSP 实现相同的行为。

Thanks in advance!提前致谢!

Using the Pivotal SSO Tile, there are two steps you need to do to make this work.使用 Pivotal SSO Tile,您需要执行两个步骤来完成这项工作。

First, you need to set up your plan using the Layer7 SiteMinder Integration Guide .首先,您需要使用Layer7 SiteMinder 集成指南设置您的计划。

As is listed there...正如那里列出的那样......

Single Sign‑On supports service provider-initiated authentication flow and single logout.单点登录支持服务提供商发起的身份验证流程和单点注销。

This is a fairly complicated process and very specific to your provider.这是一个相当复杂的过程,并且非常特定于您的提供商。 The only tip I can give you here is to do things exactly like in the docs.我可以在这里给你的唯一提示是按照文档中的方式执行操作。 It's very easy to break stuff, so following exactly what's written gives you the best chance for success.破坏东西很容易,因此完全按照所写的内容为您提供成功的最佳机会。

Once you get your plan set up, the second part would be to create a service instance using the plan & bind that to your app .设置好计划后,第二部分是使用计划创建服务实例并将其绑定到您的应用程序 Then follow the instructions for integrating your app .然后按照说明集成您的应用程序

The part to take specific note about, which is what handles the single logout is documented in the API here .需要特别注意的部分,即处理单次注销的部分记录在此处的 API 中

The logout endpoint is meant to be used by applications to log the user out of the UAA session.注销端点旨在供应用程序用于将用户从 UAA session 中注销。 UAA will only log a user out of the UAA session if they also hit this endpoint, and may also perform Single Logout with SAML providers if configured to do so.如果用户也命中此端点,UAA 只会将用户从 UAA session 中注销,并且如果配置为这样做,还可以使用 SAML 提供程序执行单点注销。

If you follow the docs for creating your service plan, it will be configured to do single logout, so you just need to make sure this endpoint is called after logging a user out in your app.如果您按照文档来创建您的服务计划,它将被配置为进行单次注销,因此您只需要确保在您的应用程序中注销用户后调用此端点。

There's an example of how you'd do this for Spring Boot apps here .这里有一个示例说明如何为 Spring 引导应用程序执行此操作

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
        UriComponents url = UriComponentsBuilder.fromHttpUrl(request.getRequestURL().toString())
                .replacePath("")
                .build();
        UriComponents redirectUrl = UriComponentsBuilder.fromHttpUrl(ssoServiceUrl)
                .path("/logout.do")
                .queryParam("client_id", clientId)
                .queryParam("redirect", url.toString())
                .build();
        response.sendRedirect(redirectUrl.toString());
    }

To explain, this code get's invoked by Spring after a successful logout.为了解释,此代码在成功注销后 由 Spring 调用 The code here is simply creating a URL to the /logout.do endpoint & issuing a redirect to the client.这里的代码只是创建一个 URL 到/logout.do端点并向客户端发出重定向。 This is what's described in the doc link above.这就是上面的文档链接中描述的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM