-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
"Missing string query parameter b'RelayState'" during SAML re-authentication #7484
Comments
Added the Supposedly the reason behind the empty string there is that in that case there isn't any reason to perform a redirect. It's worth noting that Google's SAML wasn't tested in development of this feature, but obviously we want it to work :) @sephii do you have any insight about what that string should be in Google's case? |
@anoadragon453 I have no clue what it should theoretically be. 😅 But I can tell you what happens when I click the "Sign in with single sign-on" button on Riot web, which works. Clicking this button makes a GET HTTP request to https://matrix.mydomain.com/_matrix/client/r0/login/sso/redirect?redirectUrl=https%3A%2F%2Friot.mydomain.com%2F%3Fhomeserver%3Dhttps%253A%252F%252Fmatrix.mydomain.com%26identityServer%3Dhttps%253A%252F%252Fvector.im which responds with a redirect to https://accounts.google.com/o/saml2/idp?idpid=redacted&SAMLRequest=redacted&RelayState=https%3A%2F%2Friot.mydomain.com%2F%3Fhomeserver%3Dhttps%253A%252F%252Fmatrix.mydomain.com%26identityServer%3Dhttps%253A%252F%252Fvector.im. So it seems like the |
I took another look at this using Auth0 and also didn't run into this issue. I unfortunately don't have access to a G Suite account so can't test this. We might be able to just fill in anything there, even if we never used it? There isn't an obvious value to fill in to redirect to in this case. |
We are also getting hit by this issue. If I take the link "re-authenticate with single sign-on" and add |
For SSO the client_redirect_url is set via
here: synapse/synapse/rest/client/v1/login.py Line 401 in 13a8276
But for the fallback used by cross-signing synapse/synapse/rest/client/v2_alpha/auth.py Line 175 in 13a8276
client_redirect_url = "" which is one part of the problem. If I set the value of client_redirect_url to self.hs.config.public_baseurl then the authentication works, but it does not redirect back to the Riot app as you'd expect.I'm not sure at this point how to set the client_redirect_url value so that it works with Riot desktop. |
During the SSO fallback it is not expected to redirect anywhere at the end of it, a page gets served saying "you can close this now" (with some JavaScript that would allow a client to automatically close the page). This is why the client doesn't provide a redirect URL in those cases and why it was left blank. Using something like the homeserver URL wouldn't really make sense, but sounds better than using a Riot URL. |
For reference:
|
@clokep ok in that case, my change is working for the Riot-web and possibly the best resolution for this specific issue. The issue where Riot-desktop does not appear to work with sso fallback might be another issue. |
Well described above, I can confirm this is an issue for both riot-desktop and riot-web with synapse 1.13 authenticating against a lemonldap-ng saml provider (in addition to the above reference to google). Haven't tried the hacky work around yet. As mentioned above, if the sso fallback flow is not expecting a url to redirect back to then imo either handle_saml_response should handle the response with an empty relaystate or client_redirect_url should get set (to something to prevent the fatal error). |
we have the same issue authenticating against keycloak! |
Same issue with Azure AD IDP |
If I understand #7484 (comment) correctly, it means the error is just cosmetic and the authentication succeeds even if the redirect fails, and the whole thing should work anyway? It tested again and I still can't delete devices on riot-web 1.6 with SSO. Here's what I did:
Am I doing something wrong? |
My comment was describing why the code does not provide a redirect URL from the client. It was not meant to imply that this should "work anyway". The error message is from the IdP rejecting authentication (I assume at least, I haven't been able to reproduce this). |
Since I've been unable to reproduce -- would any of the reporters here be able to try code off of a pull requests if I put up a potential fix? |
Absolutely no problem, got an SSO setup in a test environment where I can reproduce this bug. |
Did some more reading on this to remember exactly what the
I believe providing anything there will fix the issue, even if the value is unused. Anyway, I put up a fix as commit f4b450b15cdef1b650b9bf70ac52f988e05fe40a, it would be nice if someone could test. I based this on 1.13.0 so it is essentially 1.13.0 + one commit and should be fairly safe to run. |
With the proposed patch I can successfully re-authenticate using SSO/SAML and e.g. delete client sessions. So thank you very much for this fix. But it only works when using Riot in the web browser. When I try to delete a client session using the Electron version of Riot (1.6.1), I get the prompt to use Single Sign-On to re-authenticate, which opens a browser. I authenticate and am presented with the Matrix message:
The Riot application however does not register that I just re-authenticated using SSO. The prompt to re-authenticate just remains open. |
The Riot desktop issue is a separate problem, see element-hq/element-web#13719. |
I should also say -- thanks for verifying that this solution worked! 👍 I'll clean-up the PR and we'll get it in the next release version! |
@richvdh also provided a definition
|
Works for me too, thanks! |
This should be fixed in 1.14.0. Thanks for all the help debugging this! 🥳 |
Description
When using the SAML re-authentication flow (eg. when deleting devices from an account), the page with the text "A client is trying to remove device(s) from your account. To confirm this action, re-authenticate with single sign-on. If you did not expect this, your account may be compromised!" redirects to the IDP page without the
RelayState
parameter, causing the authentication to redirect to/_matrix/saml2/authn_response
without anyRelayState
parameter, causing a 400 error withMissing string query parameter b'RelayState'
.i think the problem comes from this line, which initiates the redirect with an empty URL (used as
RelayState
byhandle_redirect_request
).SSO login works fine on the other hand, where
RelayState
is correctly added to the IDP URL. I'm using Google as a SAML IDP.Steps to reproduce
/_matrix/saml2/authn_response
without aRelayState
parameter, and you get the 400 error described.i'd expect the authentication to succeed.
Version information
The text was updated successfully, but these errors were encountered: