mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
auth: Fix Apache SSO port number in confirmation links.
We had a report in the thread around https://chat.zulip.org/#narrow/stream/31-production-help/topic/Apache-based.20SSO/near/741013 that confirmation links were taking the user to the /register form on the Apache server, which of course doesn't work because the Apache server architecture we have is intended to only serve a single endpoint, /accounts/login/sso, and not any static assets (etc.). This manifested as users getting a broke page with a bunch of JS errors about missing static assets when trying to sign up for an account. The right fix is to ensure that we serve these confirmation links (and maybe in the future, redirects) to the nginx server.
This commit is contained in:
@@ -125,7 +125,19 @@ def maybe_send_to_registration(request: HttpRequest, email: str, full_name: str=
|
||||
prereg_user.invited_as = invited_as
|
||||
prereg_user.save()
|
||||
|
||||
confirmation_link = create_confirmation_link(prereg_user, request.get_host(),
|
||||
# We want to create a confirmation link to create an account
|
||||
# in the current realm, i.e. one with a hostname of
|
||||
# realm.host. For the Apache REMOTE_USER_SSO auth code path,
|
||||
# this is preferable over realm.get_host() because the latter
|
||||
# contains the port number of the Apache instance and we want
|
||||
# to send the user back to nginx. But if we're in the realm
|
||||
# creation code path, there might not be a realm yet, so we
|
||||
# have to use request.get_host().
|
||||
if realm is not None:
|
||||
host = realm.host
|
||||
else:
|
||||
host = request.get_host()
|
||||
confirmation_link = create_confirmation_link(prereg_user, host,
|
||||
Confirmation.USER_REGISTRATION)
|
||||
if is_signup:
|
||||
return redirect(confirmation_link)
|
||||
|
||||
Reference in New Issue
Block a user