Skip to content

fix: clear session cookies on SAML SLO logout to prevent stale session key - #13999

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix-saml-slo-session-cookies
Open

fix: clear session cookies on SAML SLO logout to prevent stale session key#13999
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix-saml-slo-session-cookies

Conversation

@waterWang

Copy link
Copy Markdown

Fixes: #13997

Problem

command=samlSlo (SAML Global Log Out) responds with a 302 redirect that carries no Set-Cookie header clearing JSESSIONID/userid/sessionkey. The browser therefore keeps the session key after logout, CloudStack appears to loop during sign-out, and users have to clear the browser cache (or use an incognito window) to log in again.

Root cause

SAML2LogoutAPIAuthenticatorCmd#authenticate calls resp.sendRedirect(...), which commits the response. ApiServlet's LOGOUT_API cleanup — the loop that echoes the received cookies back with an empty value and Max-Age=0 (ApiServlet L333-340) — only runs after the authenticator returns. By then the 302 is already committed, so its Set-Cookie headers are silently dropped.

Fix

Clear the session cookies (JSESSIONID, sessionkey, userid, ...) on the response before sendRedirect(...) in all four redirect paths of SAML2LogoutAPIAuthenticatorCmd, mirroring the existing cookie-cleanup loop in ApiServlet. The committed 302 now instructs the browser to drop the session cookies, and the next login starts with a fresh session key.

Testing

  • New unit test testAuthenticateClearsSessionCookiesBeforeRedirect verifies the received JSESSIONID/sessionkey cookies are cleared (Max-Age=0, empty value) and added to the response before the redirect.
  • A standalone servlet-contract simulation confirms the mechanism: cookies added after sendRedirect are dropped from the committed 302 (bug reproduced), cookies added before sendRedirect are delivered (fix verified).

…n key

Fixes: apache#13997
Signed-off-by: waterWang <672684719@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session key is not cleared when SAML Global Log Out API is called

1 participant