Skip to content
Snippets Groups Projects
Unverified Commit 92b75388 authored by Shay's avatar Shay Committed by GitHub
Browse files

Remove legacy code related to deprecated...

Remove legacy code related to deprecated `trust_identity_server_for_password_resets` config flag (#11333)

* remove code legacy code related to deprecated config flag "trust_identity_server_for_password_resets" from synapse/config/emailconfig.py

* remove legacy code supporting depreciated config flag "trust_identity_server_for_password_resets" from synapse/config/registration.py

* remove legacy code supporting depreciated config flag "trust_identity_server_for_password_resets" from synapse/handlers/identity.py

* add tests to ensure config error is thrown and synapse refuses to start when depreciated config flag is found

* add changelog

* slightly change behavior to only check for deprecated flag if set to 'true'

* Update changelog.d/11333.misc

Co-authored-by: default avatarreivilibre <oliverw@matrix.org>

Co-authored-by: default avatarreivilibre <oliverw@matrix.org>
parent 81b18fe5
No related branches found
No related tags found
No related merge requests found
Remove deprecated `trust_identity_server_for_password_resets` configuration flag.
\ No newline at end of file
...@@ -137,33 +137,14 @@ class EmailConfig(Config): ...@@ -137,33 +137,14 @@ class EmailConfig(Config):
if self.root.registration.account_threepid_delegate_email if self.root.registration.account_threepid_delegate_email
else ThreepidBehaviour.LOCAL else ThreepidBehaviour.LOCAL
) )
# Prior to Synapse v1.4.0, there was another option that defined whether Synapse would
# use an identity server to password reset tokens on its behalf. We now warn the user
# if they have this set and tell them to use the updated option, while using a default
# identity server in the process.
self.using_identity_server_from_trusted_list = False
if (
not self.root.registration.account_threepid_delegate_email
and config.get("trust_identity_server_for_password_resets", False) is True
):
# Use the first entry in self.trusted_third_party_id_servers instead
if self.trusted_third_party_id_servers:
# XXX: It's a little confusing that account_threepid_delegate_email is modified
# both in RegistrationConfig and here. We should factor this bit out
first_trusted_identity_server = self.trusted_third_party_id_servers[0] if config.get("trust_identity_server_for_password_resets"):
raise ConfigError(
# trusted_third_party_id_servers does not contain a scheme whereas 'The config option "trust_identity_server_for_password_resets" '
# account_threepid_delegate_email is expected to. Presume https 'has been replaced by "account_threepid_delegate". '
self.root.registration.account_threepid_delegate_email = ( "Please consult the sample config at docs/sample_config.yaml for "
"https://" + first_trusted_identity_server "details and update your config file."
) )
self.using_identity_server_from_trusted_list = True
else:
raise ConfigError(
"Attempted to use an identity server from"
'"trusted_third_party_id_servers" but it is empty.'
)
self.local_threepid_handling_disabled_due_to_email_config = False self.local_threepid_handling_disabled_due_to_email_config = False
if ( if (
......
...@@ -39,9 +39,7 @@ class RegistrationConfig(Config): ...@@ -39,9 +39,7 @@ class RegistrationConfig(Config):
self.registration_shared_secret = config.get("registration_shared_secret") self.registration_shared_secret = config.get("registration_shared_secret")
self.bcrypt_rounds = config.get("bcrypt_rounds", 12) self.bcrypt_rounds = config.get("bcrypt_rounds", 12)
self.trusted_third_party_id_servers = config.get(
"trusted_third_party_id_servers", ["matrix.org", "vector.im"]
)
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")
......
...@@ -464,15 +464,6 @@ class IdentityHandler: ...@@ -464,15 +464,6 @@ class IdentityHandler:
if next_link: if next_link:
params["next_link"] = next_link params["next_link"] = next_link
if self.hs.config.email.using_identity_server_from_trusted_list:
# Warn that a deprecated config option is in use
logger.warning(
'The config option "trust_identity_server_for_password_resets" '
'has been replaced by "account_threepid_delegate". '
"Please consult the sample config at docs/sample_config.yaml for "
"details and update your config file."
)
try: try:
data = await self.http_client.post_json_get_json( data = await self.http_client.post_json_get_json(
id_server + "/_matrix/identity/api/v1/validate/email/requestToken", id_server + "/_matrix/identity/api/v1/validate/email/requestToken",
...@@ -517,15 +508,6 @@ class IdentityHandler: ...@@ -517,15 +508,6 @@ class IdentityHandler:
if next_link: if next_link:
params["next_link"] = next_link params["next_link"] = next_link
if self.hs.config.email.using_identity_server_from_trusted_list:
# Warn that a deprecated config option is in use
logger.warning(
'The config option "trust_identity_server_for_password_resets" '
'has been replaced by "account_threepid_delegate". '
"Please consult the sample config at docs/sample_config.yaml for "
"details and update your config file."
)
try: try:
data = await self.http_client.post_json_get_json( data = await self.http_client.post_json_get_json(
id_server + "/_matrix/identity/api/v1/validate/msisdn/requestToken", id_server + "/_matrix/identity/api/v1/validate/msisdn/requestToken",
......
...@@ -94,3 +94,12 @@ class ConfigLoadingFileTestCase(ConfigFileTestCase): ...@@ -94,3 +94,12 @@ class ConfigLoadingFileTestCase(ConfigFileTestCase):
# The default Metrics Flags are off by default. # The default Metrics Flags are off by default.
config = HomeServerConfig.load_config("", ["-c", self.config_file]) config = HomeServerConfig.load_config("", ["-c", self.config_file])
self.assertFalse(config.metrics.metrics_flags.known_servers) self.assertFalse(config.metrics.metrics_flags.known_servers)
def test_depreciated_identity_server_flag_throws_error(self):
self.generate_config()
# Needed to ensure that actual key/value pair added below don't end up on a line with a comment
self.add_lines_to_config([" "])
# Check that presence of "trust_identity_server_for_password" throws config error
self.add_lines_to_config(["trust_identity_server_for_password_resets: true"])
with self.assertRaises(ConfigError):
HomeServerConfig.load_config("", ["-c", self.config_file])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment