-
Notifications
You must be signed in to change notification settings - Fork 59
Fix Complement not using HSPortBindingIP
(127.0.0.1
) for the homeserver BaseURL
#781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…server `BaseURL` Regressed in #776 which started using the Docker default (`0.0.0.0`). This caused downstream issues in some of our out-of-repo Complement tests which stress some SSO/OIDC login flows and expect to be using the canonical `public_baseurl` configured in Synapse.
internal/docker/deployer.go
Outdated
err = waitForPorts(ctx, d.Docker, hsDep.ContainerID) | ||
if err != nil { | ||
return fmt.Errorf("failed to get ports for container %s: %s", hsDep.ContainerID, err) | ||
return fmt.Errorf("failed to wait for ports on container %s: %s", hsDep.ContainerID, err) | ||
} | ||
baseURL, fedBaseURL, err := getHostAccessibleHomeserverUrls(ctx, d.Docker, hsDep.ContainerID, d.config.HSPortBindingIP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clean things up, I've refactored waitForPorts(...)
to only do the waiting part as described. We now assemble BaseURL
and FedBaseUrl
via getHostAccessibleHomeserverUrls(...)
As discovered by @richvdh Spawning from - #779 (comment) - #779 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks and questions.
This reverts commit da98b90.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
Co-authored-by: Richard van der Hoff <[email protected]>
Co-authored-by: Richard van der Hoff <[email protected]>
Thanks for the review @richvdh 🦘 |
Fix Complement not using
config.HSPortBindingIP
(127.0.0.1
) for the homeserverBaseURL
.Regressed in #776 which started using the Docker default
HostIP
(0.0.0.0
) because we removed the specificHSPortBindingIP
port bindings for8008
and8448
(see "Root cause" section below).Problem
This caused downstream issues in some of our out-of-repo Complement tests (Element internal) which stress some SSO/OIDC login flows with Synapse.
Before #776,
SsoRedirectServlet
received a request like thishttp://127.0.0.1:8008/_matrix/client/v3/login/sso/redirect/oidc-test_idp?redirectUrl=http%3A%2F%2Fapp.my-fake-client.io%2Fclient-callback
. But now it's seeinghttp://0.0.0.0:8008/_matrix/client/v3/login/sso/redirect/oidc-test_idp?redirectUrl=http%3A%2F%2Fapp.my-fake-client.io%2Fclient-callback
and tries to redirect to the canonicalhttp://127.0.0.1:8008/
address which would then go to the step we expect in the tests (authorization endpoint).Basically, the
host
header in the request used to be set to127.0.0.1:8008
but now it's0.0.0.0:8008
. Synapse wants to use the canonical URL so the cookies are available so it redirects you to the canonicalpublic_baseurl
version first. Relevant Synapse code that cares about using the canonical URL to get cookies back ->SsoRedirectServlet
We could alternatively, update our out-of-repo tests to account for this extra redirect but it seems more appropriate to update Complement to use the the configured
HSPortBindingIP
as expected.Root cause
The host name used in the requests during the Complement tests is from the
client.BaseURL
which is sourced from the Docker container port mapping/bindings in Complement.In #776, we removed the explicit port bindings for
8008
withHSPortBindingIP
(127.0.0.1
) so now it uses Docker's default0.0.0.0
.Dev notes
Locally link Complement package into your tests
See https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/
So you can edit the Complement source code and use it in the tests.
complement/go.mod
cd complement && go mod tidy && cd ..
Pull Request Checklist