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

Send password reset from HS: Sending the email #5345

Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dbdebc2
Ability to send password reset emails
anoadragon453 May 24, 2019
9567c60
Merge branch 'develop' into anoa/hs_password_reset_sending_email
anoadragon453 Jun 4, 2019
ed35302
Fix validation token lifetime email_ prefix
anoadragon453 Jun 4, 2019
094c351
Add changelog
anoadragon453 Jun 4, 2019
899219c
Update manifest to include txt/html template files
anoadragon453 Jun 5, 2019
309943f
Update db
anoadragon453 Jun 5, 2019
354d749
mark jinja2 and bleach as required dependencies
anoadragon453 Jun 5, 2019
62e1ec0
Add email settings to default unit test config
anoadragon453 Jun 5, 2019
a0e2a10
Update unit test template dir
anoadragon453 Jun 5, 2019
a862f2a
gen sample config
anoadragon453 Jun 5, 2019
752dbee
Merge branch 'anoa/feature_hs_password_resets' into anoa/hs_password_…
anoadragon453 Jun 5, 2019
177f024
Add html5lib as a required dep
anoadragon453 Jun 5, 2019
6d2d3c9
Modify check for smtp settings to be kinder to CI
anoadragon453 Jun 5, 2019
6394715
silly linting rules
anoadragon453 Jun 5, 2019
fe0af29
Correct html5lib dep version number
anoadragon453 Jun 5, 2019
91eac88
one more time
anoadragon453 Jun 5, 2019
c9573ca
Change template_dir to originate from synapse root dir
anoadragon453 Jun 5, 2019
4c406f5
Revert "Modify check for smtp settings to be kinder to CI"
anoadragon453 Jun 5, 2019
70b161d
Move templates. New option to disable password resets
anoadragon453 Jun 5, 2019
79bc668
Update templates and make password reset option work
anoadragon453 Jun 5, 2019
f522cde
Change jinja2 and bleach back to opt deps
anoadragon453 Jun 5, 2019
a4c0907
Update email condition requirement
anoadragon453 Jun 5, 2019
efa1a56
Only import jinja2/bleach if we need it
anoadragon453 Jun 5, 2019
6a9588c
Update sample config
anoadragon453 Jun 5, 2019
78ca92a
Revert manifest changes for new res directory
anoadragon453 Jun 5, 2019
12ed769
Remove public_baseurl from unittest config
anoadragon453 Jun 5, 2019
6efb301
infer ability to reset password from email config
anoadragon453 Jun 5, 2019
3478213
Address review comments
anoadragon453 Jun 6, 2019
a37a2f1
regen sample config
anoadragon453 Jun 6, 2019
cd4f4a2
test for ci
anoadragon453 Jun 6, 2019
92090d3
Remove CI test
anoadragon453 Jun 6, 2019
7168dee
fix bug?
anoadragon453 Jun 6, 2019
828cdbb
Run bg update on the master process
anoadragon453 Jun 6, 2019
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
Prev Previous commit
Next Next commit
infer ability to reset password from email config
anoadragon453 committed Jun 5, 2019
commit 6efb301e056b5d4644dbeac556ef595bd8615f1f
14 changes: 1 addition & 13 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
@@ -1006,18 +1006,6 @@ signing_key_path: "CONFDIR/SERVERNAME.signing.key"
# algorithm: "HS256"


# Allow users to reset their password
#
# Resetting a user's password is done either by sending a token from
# Synapse, or asking an identity server to do so. In Synapse v1.0,
# sending a password reset token from an identity server was turned off
# by default for security reasons.
#
# If enable_password_reset_from_is is False, you must fill out the
# "email" section of the config before enabling password resets
#
#enable_password_resets: False

password_config:
# Uncomment to disable password login
#
@@ -1031,7 +1019,7 @@ password_config:


# Enable sending emails for password resets, notification events or
# account expiry notices
# account expiry notices.
#
# If your SMTP server requires authentication, the optional smtp_user &
# smtp_pass variables should be used
10 changes: 9 additions & 1 deletion synapse/config/emailconfig.py
Original file line number Diff line number Diff line change
@@ -77,6 +77,14 @@ def read_config(self, config):
self.email_enable_password_reset_from_is = email_config.get(
"enable_password_reset_from_is", False,
)
self.enable_password_resets = (
self.email_enable_password_reset_from_is
or (not self.email_enable_password_reset_from_is and email_config != {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this just self.enable_password_resets = self.email_enable_password_reset_from_is or email_config != {}?

)
if email_config == {} and not self.email_enable_password_reset_from_is:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if email_config == {} and not self.email_enable_password_reset_from_is:
if not self.enable_password_resets:

logger.warn(
"User password resets have been disabled due to lack of email config."
)

self.email_validation_token_lifetime = email_config.get(
"validation_token_lifetime", 15 * 60,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self.parse_duration so that you can say 15m in the config. We probably want to keep this valid for, like, 1h at least, since email can be quite slow at times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should be in milliseconds for consistency

@@ -206,7 +214,7 @@ def _get_template_content(self, template_dir, path):
def default_config(self, config_dir_path, server_name, **kwargs):
return """
# Enable sending emails for password resets, notification events or
# account expiry notices
# account expiry notices.
#
# If your SMTP server requires authentication, the optional smtp_user &
# smtp_pass variables should be used
14 changes: 0 additions & 14 deletions synapse/config/password.py
Original file line number Diff line number Diff line change
@@ -21,8 +21,6 @@ class PasswordConfig(Config):
"""

def read_config(self, config):
self.enable_password_resets = config.get("enable_password_resets", False)

password_config = config.get("password_config", {})
if password_config is None:
password_config = {}
@@ -32,18 +30,6 @@ def read_config(self, config):

def default_config(self, config_dir_path, server_name, **kwargs):
return """\
# Allow users to reset their password
#
# Resetting a user's password is done either by sending a token from
# Synapse, or asking an identity server to do so. In Synapse v1.0,
# sending a password reset token from an identity server was turned off
# by default for security reasons.
#
# If enable_password_reset_from_is is False, you must fill out the
# "email" section of the config before enabling password resets
#
#enable_password_resets: False

password_config:
# Uncomment to disable password login
#