-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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:
- 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.
- CloudStack redirects to IdP for authentication:
- CloudStack (as SP) redirects the user to
/saml/authon the app, passing aSAMLRequest.
- CloudStack (as SP) redirects the user to
- 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.
- My app validates the request and renders a form that auto-submits the
- 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.
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
- Use your application as SAML IdP
- 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
