Skip to content

SAML Auth is broken after the 4.19.2 upgrade #10877

@OlegChuev

Description

@OlegChuev

problem

My application serves as a SAML Identity Provider (IdP) and reverse proxy for accessing the ACS.
After the recent update to version 4.19.2, the SAML integration has stopped working correctly — authorization now fails with a 401 Unauthorized response (please refer to the attached videos)

Flow Overview:

  1. User tries to access CloudStack UI (e.g., /cloudstack/client/):
    • The request is routed through the app, which acts as a reverse proxy
    • If the user is not signed in, they see an unauthorized page with a link to sign in.
  2. CloudStack redirects to IdP for authentication:
    • CloudStack (as SP) redirects the user to /saml/auth on the app, passing a SAMLRequest.
  3. IdP handles the SAMLRequest:
    • My app validates the request and renders a form that auto-submits the SAMLRequest.
    • If the user is authenticated, app generates a SAMLResponse and posts it back to CloudStack’s Assertion Consumer Service (ACS) endpoint. If not authenticated, the user is prompted to log in.
  4. CloudStack consumes the SAMLResponse:
    • CloudStack validates the SAMLResponse, logs the user in, and grants access to the UI.
User ---> My App (IdP) ←→ CloudStack (SP)
   |         |                        |
   |         |---- SAML Auth -------->|
   |         |<--- SAMLRequest -------|
   |         |---- SAMLResponse ----->|
   |         |                        |
   |---- Reverse Proxy to CloudStack -|

The change introduced in PR #10047, particularly this line:

resp.addHeader("SET-COOKIE", String.format("%s=%s;HttpOnly;Path=/client/api;%s", ApiConstants.SESSIONKEY, loginResponse.getSessionKey(), sameSite));

…seems to break the flow by setting the HttpOnly flag on the sessionkey cookie.
As a result, the sessionkey is no longer accessible to the frontend JavaScript (ui/src/api/index.js), which expects to be able to read it (as far as I understood at least).

This appears to conflict with an earlier change made in this commit, where it looks like the frontend relies on accessing the sessionKey via JS


Behavior with HttpOnly header:

4.19.2_with_header.mov

Behavior without HttpOnly header:

4.19.2_without_header.mov

I also have tried tweaking api.sessionkey.check.locations and api.sessionkey.cookie.samesite, but none of the options helped. I also attached an example of my SAML settings, perhaps that might help.

Image

I’d really appreciate your thoughts on what might be the most suitable solution in this case.

versions

4.19.2.0

The steps to reproduce the bug

  1. Use your application as SAML IdP
  2. Authorize request in your application and redirect to the login page

Actual result: 401 unauthorized
Expected result: user is authorized as expected

What to do about it?

I tried removing the HttpOnly flag from resp.addHeader(...), and it seems to resolve the issue.
To be honest, I’m not entirely sure how to approach this properly since I'm not really familiar with java and ACS logic

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions