Skip to content

Commit

Permalink
fix: SAML Logout not working - EXO-60293
Browse files Browse the repository at this point in the history
Before this fix, when login out from saml, the request /portal/doling?GLO=true try to flush 3 cookies (JSESSIONID, rememberme, and oauth_rememberme), do setCookie with empty value.
This not flush cookie in browser because cookies path is '/' and not '/portal'
In addition, there is one more cookie to flush, which currently recreate the user session.

This commit use the correct path for the cookies and add the JSESSIONIDSSO cookie which should be flushed.

Resolves meeds-io/meeds-1771
  • Loading branch information
rdenarie committed Mar 25, 2024
1 parent 6fc7d16 commit aa15664
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class PortalSAML2LogOutHandler extends SAML2LogOutHandler

private static final String OAUTH_COOKIE_NAME = "oauth_rememberme";

private static final String JSESSIONIDSSO_COOKIE_NAME = "JSESSIONIDSSO";

private final SPLogOutHandler sp = new SPLogOutHandler();

private static Log log = ExoLogger.getLogger(PortalSAML2LogOutHandler.class);
Expand Down Expand Up @@ -146,7 +148,9 @@ protected void portalLogout(HttpServletRequest request, HttpServletResponse resp

try
{
ServletContainerFactory.getServletContainer().logout(request, response);
if (request.getRemoteUser()!=null) {
ServletContainerFactory.getServletContainer().logout(request, response);
}
}
catch (Exception e)
{
Expand All @@ -155,9 +159,15 @@ protected void portalLogout(HttpServletRequest request, HttpServletResponse resp

// Remove rememberme cookie
Cookie cookie = new Cookie(COOKIE_NAME, "");
cookie.setPath(request.getContextPath());
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);

// Remove JSESSIONIDSSO cookie
Cookie jsessionIdSSOCookie = new Cookie(JSESSIONIDSSO_COOKIE_NAME, "");
jsessionIdSSOCookie.setPath("/");
jsessionIdSSOCookie.setMaxAge(0);
response.addCookie(jsessionIdSSOCookie);

// Remove oauth cookie
Cookie oauthCookie = new Cookie(OAUTH_COOKIE_NAME, "");
Expand Down

0 comments on commit aa15664

Please sign in to comment.