mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 22:39:26 -05:00
Merge remote-tracking branch 'origin/develop' into release-v1.26.0
This commit is contained in:
commit
6c0dfd2e8e
1
changelog.d/9159.feature
Normal file
1
changelog.d/9159.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Give the `public_baseurl` a default value, if it is not explicitly set in the configuration file.
|
@ -67,11 +67,16 @@ pid_file: DATADIR/homeserver.pid
|
|||||||
#
|
#
|
||||||
#web_client_location: https://riot.example.com/
|
#web_client_location: https://riot.example.com/
|
||||||
|
|
||||||
# The public-facing base URL that clients use to access this HS
|
# The public-facing base URL that clients use to access this Homeserver (not
|
||||||
# (not including _matrix/...). This is the same URL a user would
|
# including _matrix/...). This is the same URL a user might enter into the
|
||||||
# enter into the 'custom HS URL' field on their client. If you
|
# 'Custom Homeserver URL' field on their client. If you use Synapse with a
|
||||||
# use synapse with a reverse proxy, this should be the URL to reach
|
# reverse proxy, this should be the URL to reach Synapse via the proxy.
|
||||||
# synapse via the proxy.
|
# Otherwise, it should be the URL to reach Synapse's client HTTP listener (see
|
||||||
|
# 'listeners' below).
|
||||||
|
#
|
||||||
|
# If this is left unset, it defaults to 'https://<server_name>/'. (Note that
|
||||||
|
# that will not work unless you configure Synapse or a reverse-proxy to listen
|
||||||
|
# on port 443.)
|
||||||
#
|
#
|
||||||
#public_baseurl: https://example.com/
|
#public_baseurl: https://example.com/
|
||||||
|
|
||||||
@ -1150,8 +1155,9 @@ account_validity:
|
|||||||
# send an email to the account's email address with a renewal link. By
|
# send an email to the account's email address with a renewal link. By
|
||||||
# default, no such emails are sent.
|
# default, no such emails are sent.
|
||||||
#
|
#
|
||||||
# If you enable this setting, you will also need to fill out the 'email' and
|
# If you enable this setting, you will also need to fill out the 'email'
|
||||||
# 'public_baseurl' configuration sections.
|
# configuration section. You should also check that 'public_baseurl' is set
|
||||||
|
# correctly.
|
||||||
#
|
#
|
||||||
#renew_at: 1w
|
#renew_at: 1w
|
||||||
|
|
||||||
@ -1242,8 +1248,7 @@ account_validity:
|
|||||||
# The identity server which we suggest that clients should use when users log
|
# The identity server which we suggest that clients should use when users log
|
||||||
# in on this server.
|
# in on this server.
|
||||||
#
|
#
|
||||||
# (By default, no suggestion is made, so it is left up to the client.
|
# (By default, no suggestion is made, so it is left up to the client.)
|
||||||
# This setting is ignored unless public_baseurl is also set.)
|
|
||||||
#
|
#
|
||||||
#default_identity_server: https://matrix.org
|
#default_identity_server: https://matrix.org
|
||||||
|
|
||||||
@ -1268,8 +1273,6 @@ account_validity:
|
|||||||
# by the Matrix Identity Service API specification:
|
# by the Matrix Identity Service API specification:
|
||||||
# https://matrix.org/docs/spec/identity_service/latest
|
# https://matrix.org/docs/spec/identity_service/latest
|
||||||
#
|
#
|
||||||
# If a delegate is specified, the config option public_baseurl must also be filled out.
|
|
||||||
#
|
|
||||||
account_threepid_delegates:
|
account_threepid_delegates:
|
||||||
#email: https://example.com # Delegate email sending to example.com
|
#email: https://example.com # Delegate email sending to example.com
|
||||||
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
|
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
|
||||||
@ -1901,9 +1904,9 @@ sso:
|
|||||||
# phishing attacks from evil.site. To avoid this, include a slash after the
|
# phishing attacks from evil.site. To avoid this, include a slash after the
|
||||||
# hostname: "https://my.client/".
|
# hostname: "https://my.client/".
|
||||||
#
|
#
|
||||||
# If public_baseurl is set, then the login fallback page (used by clients
|
# The login fallback page (used by clients that don't natively support the
|
||||||
# that don't natively support the required login flows) is whitelisted in
|
# required login flows) is automatically whitelisted in addition to any URLs
|
||||||
# addition to any URLs in this list.
|
# in this list.
|
||||||
#
|
#
|
||||||
# By default, this list is empty.
|
# By default, this list is empty.
|
||||||
#
|
#
|
||||||
|
@ -42,8 +42,6 @@ class ConsentURIBuilder:
|
|||||||
"""
|
"""
|
||||||
if hs_config.form_secret is None:
|
if hs_config.form_secret is None:
|
||||||
raise ConfigError("form_secret not set in config")
|
raise ConfigError("form_secret not set in config")
|
||||||
if hs_config.public_baseurl is None:
|
|
||||||
raise ConfigError("public_baseurl not set in config")
|
|
||||||
|
|
||||||
self._hmac_secret = hs_config.form_secret.encode("utf-8")
|
self._hmac_secret = hs_config.form_secret.encode("utf-8")
|
||||||
self._public_baseurl = hs_config.public_baseurl
|
self._public_baseurl = hs_config.public_baseurl
|
||||||
|
@ -252,10 +252,11 @@ class Config:
|
|||||||
env = jinja2.Environment(loader=loader, autoescape=autoescape)
|
env = jinja2.Environment(loader=loader, autoescape=autoescape)
|
||||||
|
|
||||||
# Update the environment with our custom filters
|
# Update the environment with our custom filters
|
||||||
env.filters.update({"format_ts": _format_ts_filter})
|
|
||||||
if self.public_baseurl:
|
|
||||||
env.filters.update(
|
env.filters.update(
|
||||||
{"mxc_to_http": _create_mxc_to_http_filter(self.public_baseurl)}
|
{
|
||||||
|
"format_ts": _format_ts_filter,
|
||||||
|
"mxc_to_http": _create_mxc_to_http_filter(self.public_baseurl),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
@ -166,11 +166,6 @@ class EmailConfig(Config):
|
|||||||
if not self.email_notif_from:
|
if not self.email_notif_from:
|
||||||
missing.append("email.notif_from")
|
missing.append("email.notif_from")
|
||||||
|
|
||||||
# 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")
|
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
MISSING_PASSWORD_RESET_CONFIG_ERROR % (", ".join(missing),)
|
MISSING_PASSWORD_RESET_CONFIG_ERROR % (", ".join(missing),)
|
||||||
@ -269,9 +264,6 @@ class EmailConfig(Config):
|
|||||||
if not self.email_notif_from:
|
if not self.email_notif_from:
|
||||||
missing.append("email.notif_from")
|
missing.append("email.notif_from")
|
||||||
|
|
||||||
if config.get("public_baseurl") is None:
|
|
||||||
missing.append("public_baseurl")
|
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
"email.enable_notifs is True but required keys are missing: %s"
|
"email.enable_notifs is True but required keys are missing: %s"
|
||||||
|
@ -43,8 +43,6 @@ class OIDCConfig(Config):
|
|||||||
raise ConfigError(e.message) from e
|
raise ConfigError(e.message) from e
|
||||||
|
|
||||||
public_baseurl = self.public_baseurl
|
public_baseurl = self.public_baseurl
|
||||||
if public_baseurl is None:
|
|
||||||
raise ConfigError("oidc_config requires a public_baseurl to be set")
|
|
||||||
self.oidc_callback_url = public_baseurl + "_synapse/oidc/callback"
|
self.oidc_callback_url = public_baseurl + "_synapse/oidc/callback"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -49,10 +49,6 @@ class AccountValidityConfig(Config):
|
|||||||
|
|
||||||
self.startup_job_max_delta = self.period * 10.0 / 100.0
|
self.startup_job_max_delta = self.period * 10.0 / 100.0
|
||||||
|
|
||||||
if self.renew_by_email_enabled:
|
|
||||||
if "public_baseurl" not in synapse_config:
|
|
||||||
raise ConfigError("Can't send renewal emails without 'public_baseurl'")
|
|
||||||
|
|
||||||
template_dir = config.get("template_dir")
|
template_dir = config.get("template_dir")
|
||||||
|
|
||||||
if not template_dir:
|
if not template_dir:
|
||||||
@ -109,13 +105,6 @@ class RegistrationConfig(Config):
|
|||||||
account_threepid_delegates = config.get("account_threepid_delegates") or {}
|
account_threepid_delegates = config.get("account_threepid_delegates") or {}
|
||||||
self.account_threepid_delegate_email = account_threepid_delegates.get("email")
|
self.account_threepid_delegate_email = account_threepid_delegates.get("email")
|
||||||
self.account_threepid_delegate_msisdn = account_threepid_delegates.get("msisdn")
|
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.default_identity_server = config.get("default_identity_server")
|
||||||
self.allow_guest_access = config.get("allow_guest_access", False)
|
self.allow_guest_access = config.get("allow_guest_access", False)
|
||||||
@ -240,8 +229,9 @@ class RegistrationConfig(Config):
|
|||||||
# send an email to the account's email address with a renewal link. By
|
# send an email to the account's email address with a renewal link. By
|
||||||
# default, no such emails are sent.
|
# default, no such emails are sent.
|
||||||
#
|
#
|
||||||
# If you enable this setting, you will also need to fill out the 'email' and
|
# If you enable this setting, you will also need to fill out the 'email'
|
||||||
# 'public_baseurl' configuration sections.
|
# configuration section. You should also check that 'public_baseurl' is set
|
||||||
|
# correctly.
|
||||||
#
|
#
|
||||||
#renew_at: 1w
|
#renew_at: 1w
|
||||||
|
|
||||||
@ -332,8 +322,7 @@ class RegistrationConfig(Config):
|
|||||||
# The identity server which we suggest that clients should use when users log
|
# The identity server which we suggest that clients should use when users log
|
||||||
# in on this server.
|
# in on this server.
|
||||||
#
|
#
|
||||||
# (By default, no suggestion is made, so it is left up to the client.
|
# (By default, no suggestion is made, so it is left up to the client.)
|
||||||
# This setting is ignored unless public_baseurl is also set.)
|
|
||||||
#
|
#
|
||||||
#default_identity_server: https://matrix.org
|
#default_identity_server: https://matrix.org
|
||||||
|
|
||||||
@ -358,8 +347,6 @@ class RegistrationConfig(Config):
|
|||||||
# by the Matrix Identity Service API specification:
|
# by the Matrix Identity Service API specification:
|
||||||
# https://matrix.org/docs/spec/identity_service/latest
|
# https://matrix.org/docs/spec/identity_service/latest
|
||||||
#
|
#
|
||||||
# If a delegate is specified, the config option public_baseurl must also be filled out.
|
|
||||||
#
|
|
||||||
account_threepid_delegates:
|
account_threepid_delegates:
|
||||||
#email: https://example.com # Delegate email sending to example.com
|
#email: https://example.com # Delegate email sending to example.com
|
||||||
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
|
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
|
||||||
|
@ -189,8 +189,6 @@ class SAML2Config(Config):
|
|||||||
import saml2
|
import saml2
|
||||||
|
|
||||||
public_baseurl = self.public_baseurl
|
public_baseurl = self.public_baseurl
|
||||||
if public_baseurl is None:
|
|
||||||
raise ConfigError("saml2_config requires a public_baseurl to be set")
|
|
||||||
|
|
||||||
if self.saml2_grandfathered_mxid_source_attribute:
|
if self.saml2_grandfathered_mxid_source_attribute:
|
||||||
optional_attributes.add(self.saml2_grandfathered_mxid_source_attribute)
|
optional_attributes.add(self.saml2_grandfathered_mxid_source_attribute)
|
||||||
|
@ -161,7 +161,11 @@ class ServerConfig(Config):
|
|||||||
self.print_pidfile = config.get("print_pidfile")
|
self.print_pidfile = config.get("print_pidfile")
|
||||||
self.user_agent_suffix = config.get("user_agent_suffix")
|
self.user_agent_suffix = config.get("user_agent_suffix")
|
||||||
self.use_frozen_dicts = config.get("use_frozen_dicts", False)
|
self.use_frozen_dicts = config.get("use_frozen_dicts", False)
|
||||||
self.public_baseurl = config.get("public_baseurl")
|
self.public_baseurl = config.get("public_baseurl") or "https://%s/" % (
|
||||||
|
self.server_name,
|
||||||
|
)
|
||||||
|
if self.public_baseurl[-1] != "/":
|
||||||
|
self.public_baseurl += "/"
|
||||||
|
|
||||||
# Whether to enable user presence.
|
# Whether to enable user presence.
|
||||||
self.use_presence = config.get("use_presence", True)
|
self.use_presence = config.get("use_presence", True)
|
||||||
@ -317,9 +321,6 @@ class ServerConfig(Config):
|
|||||||
# Always blacklist 0.0.0.0, ::
|
# Always blacklist 0.0.0.0, ::
|
||||||
self.federation_ip_range_blacklist.update(["0.0.0.0", "::"])
|
self.federation_ip_range_blacklist.update(["0.0.0.0", "::"])
|
||||||
|
|
||||||
if self.public_baseurl is not None:
|
|
||||||
if self.public_baseurl[-1] != "/":
|
|
||||||
self.public_baseurl += "/"
|
|
||||||
self.start_pushers = config.get("start_pushers", True)
|
self.start_pushers = config.get("start_pushers", True)
|
||||||
|
|
||||||
# (undocumented) option for torturing the worker-mode replication a bit,
|
# (undocumented) option for torturing the worker-mode replication a bit,
|
||||||
@ -740,11 +741,16 @@ class ServerConfig(Config):
|
|||||||
#
|
#
|
||||||
#web_client_location: https://riot.example.com/
|
#web_client_location: https://riot.example.com/
|
||||||
|
|
||||||
# The public-facing base URL that clients use to access this HS
|
# The public-facing base URL that clients use to access this Homeserver (not
|
||||||
# (not including _matrix/...). This is the same URL a user would
|
# including _matrix/...). This is the same URL a user might enter into the
|
||||||
# enter into the 'custom HS URL' field on their client. If you
|
# 'Custom Homeserver URL' field on their client. If you use Synapse with a
|
||||||
# use synapse with a reverse proxy, this should be the URL to reach
|
# reverse proxy, this should be the URL to reach Synapse via the proxy.
|
||||||
# synapse via the proxy.
|
# Otherwise, it should be the URL to reach Synapse's client HTTP listener (see
|
||||||
|
# 'listeners' below).
|
||||||
|
#
|
||||||
|
# If this is left unset, it defaults to 'https://<server_name>/'. (Note that
|
||||||
|
# that will not work unless you configure Synapse or a reverse-proxy to listen
|
||||||
|
# on port 443.)
|
||||||
#
|
#
|
||||||
#public_baseurl: https://example.com/
|
#public_baseurl: https://example.com/
|
||||||
|
|
||||||
|
@ -64,9 +64,6 @@ class SSOConfig(Config):
|
|||||||
# gracefully to the client). This would make it pointless to ask the user for
|
# gracefully to the client). This would make it pointless to ask the user for
|
||||||
# confirmation, since the URL the confirmation page would be showing wouldn't be
|
# confirmation, since the URL the confirmation page would be showing wouldn't be
|
||||||
# the client's.
|
# the client's.
|
||||||
# public_baseurl is an optional setting, so we only add the fallback's URL to the
|
|
||||||
# list if it's provided (because we can't figure out what that URL is otherwise).
|
|
||||||
if self.public_baseurl:
|
|
||||||
login_fallback_url = self.public_baseurl + "_matrix/static/client/login"
|
login_fallback_url = self.public_baseurl + "_matrix/static/client/login"
|
||||||
self.sso_client_whitelist.append(login_fallback_url)
|
self.sso_client_whitelist.append(login_fallback_url)
|
||||||
|
|
||||||
@ -86,9 +83,9 @@ class SSOConfig(Config):
|
|||||||
# phishing attacks from evil.site. To avoid this, include a slash after the
|
# phishing attacks from evil.site. To avoid this, include a slash after the
|
||||||
# hostname: "https://my.client/".
|
# hostname: "https://my.client/".
|
||||||
#
|
#
|
||||||
# If public_baseurl is set, then the login fallback page (used by clients
|
# The login fallback page (used by clients that don't natively support the
|
||||||
# that don't natively support the required login flows) is whitelisted in
|
# required login flows) is automatically whitelisted in addition to any URLs
|
||||||
# addition to any URLs in this list.
|
# in this list.
|
||||||
#
|
#
|
||||||
# By default, this list is empty.
|
# By default, this list is empty.
|
||||||
#
|
#
|
||||||
|
@ -476,8 +476,6 @@ class IdentityHandler(BaseHandler):
|
|||||||
except RequestTimedOutError:
|
except RequestTimedOutError:
|
||||||
raise SynapseError(500, "Timed out contacting identity server")
|
raise SynapseError(500, "Timed out contacting identity server")
|
||||||
|
|
||||||
assert self.hs.config.public_baseurl
|
|
||||||
|
|
||||||
# we need to tell the client to send the token back to us, since it doesn't
|
# 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
|
# otherwise know where to send it, so add submit_url response parameter
|
||||||
# (see also MSC2078)
|
# (see also MSC2078)
|
||||||
|
@ -34,10 +34,6 @@ class WellKnownBuilder:
|
|||||||
self._config = hs.config
|
self._config = hs.config
|
||||||
|
|
||||||
def get_well_known(self):
|
def get_well_known(self):
|
||||||
# if we don't have a public_baseurl, we can't help much here.
|
|
||||||
if self._config.public_baseurl is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
result = {"m.homeserver": {"base_url": self._config.public_baseurl}}
|
result = {"m.homeserver": {"base_url": self._config.public_baseurl}}
|
||||||
|
|
||||||
if self._config.default_identity_server:
|
if self._config.default_identity_server:
|
||||||
|
@ -40,12 +40,3 @@ class WellKnownTests(unittest.HomeserverTestCase):
|
|||||||
"m.identity_server": {"base_url": "https://testis"},
|
"m.identity_server": {"base_url": "https://testis"},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_well_known_no_public_baseurl(self):
|
|
||||||
self.hs.config.public_baseurl = None
|
|
||||||
|
|
||||||
channel = self.make_request(
|
|
||||||
"GET", "/.well-known/matrix/client", shorthand=False
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(channel.code, 404)
|
|
||||||
|
@ -159,7 +159,6 @@ def default_config(name, parse=False):
|
|||||||
"remote": {"per_second": 10000, "burst_count": 10000},
|
"remote": {"per_second": 10000, "burst_count": 10000},
|
||||||
},
|
},
|
||||||
"saml2_enabled": False,
|
"saml2_enabled": False,
|
||||||
"public_baseurl": None,
|
|
||||||
"default_identity_server": None,
|
"default_identity_server": None,
|
||||||
"key_refresh_interval": 24 * 60 * 60 * 1000,
|
"key_refresh_interval": 24 * 60 * 60 * 1000,
|
||||||
"old_signing_keys": {},
|
"old_signing_keys": {},
|
||||||
|
Loading…
Reference in New Issue
Block a user