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

Commit

Permalink
Remove assertion and provide a clear warning on startup for missing p…
Browse files Browse the repository at this point in the history
…ublic_baseurl (#6379)

* commit 'ce578031f':
  Remove assertion and provide a clear warning on startup for missing public_baseurl (#6379)
  • Loading branch information
anoadragon453 committed Mar 18, 2020
2 parents 68096ca + ce57803 commit 2de57b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
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.
2 changes: 2 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
7 changes: 7 additions & 0 deletions synapse/config/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def read_config(self, config, **kwargs):
account_threepid_delegates = config.get("account_threepid_delegates") or {}
self.account_threepid_delegate_email = account_threepid_delegates.get("email")
self.account_threepid_delegate_msisdn = account_threepid_delegates.get("msisdn")
if self.account_threepid_delegate_msisdn and 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`."
)

self.default_identity_server = config.get("default_identity_server")
self.allow_guest_access = config.get("allow_guest_access", False)
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 @@ -207,6 +207,7 @@ def test_advertised_flows(self):

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

0 comments on commit 2de57b8

Please sign in to comment.