Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Provide a clear warning on startup for missing public_baseurl #6379

Merged
merged 4 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6379.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Complain on startup instead of 500'ing during runtime when `public_baseurl` isn't set when necessary.
10 changes: 10 additions & 0 deletions synapse/config/emailconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def read_config(self, config, **kwargs):
if k not in email_config:
missing.append("email." + k)

# public_baseurl is required to build password reset and validation links that
# will be emailed to users
if config.get("public_baseurl") is None:
missing.append("public_baseurl")

Expand Down Expand Up @@ -238,6 +240,14 @@ def read_config(self, config, **kwargs):
self.email_add_threepid_template_success_html_content = self.read_file(
filepath, "email.add_threepid_template_success_html"
)
elif self.account_threepid_delegate_msisdn:
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
if not self.public_baseurl:
raise ConfigError(
"The configuration option `public_baseurl` is required if "
"`account_threepid_delegate.msisdn` is set, such that "
"clients know where to submit validation tokens to. Please "
"configure `public_baseurl`."
)

if self.email_enable_notifs:
required = [
Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ def requestMsisdnToken(
except TimeoutError:
raise SynapseError(500, "Timed out contacting identity server")

assert self.hs.config.public_baseurl
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved

# we need to tell the client to send the token back to us, since it doesn't
# otherwise know where to send it, so add submit_url response parameter
# (see also MSC2078)
Expand Down
1 change: 1 addition & 0 deletions tests/rest/client/v2_alpha/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def test_advertised_flows(self):

@unittest.override_config(
{
"public_baseurl": "https://test_server",
"enable_registration_captcha": True,
"user_consent": {
"version": "1",
Expand Down