-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Replace trust_identity_server_for_password_resets with account_threepid_delegate #5876
Changes from 2 commits
09a3bb6
98191da
52f1444
a148bba
5d9f48d
3ba7304
cfe7309
e65faf5
03a6eee
816fcd1
0d2a024
f683e3b
93bd5df
a94cf0d
ed3ff55
e395133
8aa1a4c
4d92ad6
a7f619d
512d094
76ca096
37b0ce3
00bca3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Replace `trust_identity_server_for_password_resets` config option with `account_threepid_delegate`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,19 +74,33 @@ def read_config(self, config, **kwargs): | |
"renew_at" | ||
) | ||
|
||
email_trust_identity_server_for_password_resets = email_config.get( | ||
"trust_identity_server_for_password_resets", False | ||
self.email_threepid_behaviour = ( | ||
# Have Synapse handle the email sending if account_threepid_delegate | ||
# is not defined | ||
"remote" | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if self.account_threepid_delegate | ||
else "local" | ||
) | ||
self.email_password_reset_behaviour = ( | ||
"remote" if email_trust_identity_server_for_password_resets else "local" | ||
) | ||
self.password_resets_were_disabled_due_to_email_config = False | ||
if self.email_password_reset_behaviour == "local" and email_config == {}: | ||
# Prior to Synapse v1.4.0, there used to be another option that defined whether Synapse | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't warn but kills synapse. I'd strongly prefer to avoid doing this, as otherwise we need to scream from the roof tops that the upgrade may cause your synapse to not start. Can we do something backwards compatible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to know what identity server they'd prefer to use to handle registration and password resets. We could just warn them with a message on startup without blocking Synapse start? Not exactly sure where in the codebase we could put the message though, given we can't log here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the old behaviour? Of using the first entry in trusted_id_servers, or whatever it does now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can, though that's another thing relying on the trusted id servers list. Though this should also be eventually removed, so I say that could probably work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though if their There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is what I've done. |
||
# TODO: Eventually we want to remove the functionality of having an identity server | ||
# send tokens on behalf of the homeserver. At that point, we should remove this check | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if config.get("trust_identity_server_for_password_resets", False) is True: | ||
raise ConfigError( | ||
'The config option "trust_identity_server_for_password_resets" ' | ||
'has been replaced by "account_threepid_delegate". Please ' | ||
"consult the default config at docs/sample_config.yaml for " | ||
"details and update your config file." | ||
) | ||
|
||
self.local_threepid_emails_disabled_due_to_config = False | ||
if self.email_threepid_behaviour == "local" and email_config == {}: | ||
# We cannot warn the user this has happened here | ||
# Instead do so when a user attempts to reset their password | ||
self.password_resets_were_disabled_due_to_email_config = True | ||
self.local_threepid_emails_disabled_due_to_config = True | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
self.email_password_reset_behaviour = "off" | ||
self.email_threepid_behaviour = "off" | ||
|
||
# Get lifetime of a validation token in milliseconds | ||
self.email_validation_token_lifetime = self.parse_duration( | ||
|
@@ -96,7 +110,7 @@ def read_config(self, config, **kwargs): | |
if ( | ||
self.email_enable_notifs | ||
or account_validity_renewal_enabled | ||
or self.email_password_reset_behaviour == "local" | ||
or self.email_threepid_behaviour == "local" | ||
): | ||
# make sure we can import the required deps | ||
import jinja2 | ||
|
@@ -106,7 +120,7 @@ def read_config(self, config, **kwargs): | |
jinja2 | ||
bleach | ||
|
||
if self.email_password_reset_behaviour == "local": | ||
if self.email_threepid_behaviour == "local": | ||
required = ["smtp_host", "smtp_port", "notif_from"] | ||
|
||
missing = [] | ||
|
@@ -239,19 +253,6 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs): | |
# # | ||
# riot_base_url: "http://localhost/riot" | ||
# | ||
# # Enable sending password reset emails via the configured, trusted | ||
# # identity servers | ||
# # | ||
# # IMPORTANT! This will give a malicious or overtaken identity server | ||
# # the ability to reset passwords for your users! Make absolutely sure | ||
# # that you want to do this! It is strongly recommended that password | ||
# # reset emails be sent by the homeserver instead | ||
# # | ||
# # If this option is set to false and SMTP options have not been | ||
# # configured, resetting user passwords via email will be disabled | ||
# # | ||
# #trust_identity_server_for_password_resets: false | ||
# | ||
# # Configure the time that a validation email or text message code | ||
# # will expire after sending | ||
# # | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,12 +458,9 @@ def _check_threepid(self, medium, authdict, password_servlet=False, **kwargs): | |
identity_handler = self.hs.get_handlers().identity_handler | ||
|
||
logger.info("Getting validated threepid. threepidcreds: %r", (threepid_creds,)) | ||
if ( | ||
not password_servlet | ||
or self.hs.config.email_password_reset_behaviour == "remote" | ||
): | ||
if not password_servlet or self.hs.config.email_threepid_behaviour == "remote": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is doing this for non password reset still the correct thing to do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to be removed in part 2 of #5835 |
||
threepid = yield identity_handler.threepid_from_creds(threepid_creds) | ||
elif self.hs.config.email_password_reset_behaviour == "local": | ||
elif self.hs.config.email_threepid_behaviour == "local": | ||
row = yield self.store.get_threepid_validation_session( | ||
medium, | ||
threepid_creds["client_secret"], | ||
|
Uh oh!
There was an error while loading. Please reload this page.