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

add option to disable changes to the 3PIDs for an account. #3180

Merged
merged 2 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions synapse/config/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def read_config(self, config):
"check_is_for_allowed_local_3pids", None
)
self.allow_invited_3pids = config.get("allow_invited_3pids", False)

self.disable_3pid_changes = config.get("disable_3pid_changes", False)

self.registration_shared_secret = config.get("registration_shared_secret")

self.bcrypt_rounds = config.get("bcrypt_rounds", 12)
Expand Down Expand Up @@ -89,6 +92,11 @@ def default_config(self, **kwargs):
# - medium: msisdn
# pattern: "\\+44"

# If true, stop users from trying to change the 3PIDs associated with
# their accounts.
#
# disable_3pid_changes: False

# If set, allows registration by anyone who also has the shared
# secret, even if registration is otherwise disabled.
registration_shared_secret: "%(registration_shared_secret)s"
Expand Down
6 changes: 6 additions & 0 deletions synapse/rest/client/v2_alpha/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ def on_GET(self, request):
def on_POST(self, request):
yield run_on_reactor()

if self.hs.config.disable_3pid_changes:
raise SynapseError(400, "3PID changes disabled on this server")

body = parse_json_object_from_request(request)

threePidCreds = body.get('threePidCreds')
Expand Down Expand Up @@ -367,6 +370,9 @@ def __init__(self, hs):
def on_POST(self, request):
yield run_on_reactor()

if self.hs.config.disable_3pid_changes:
raise SynapseError(400, "3PID changes disabled on this server")

body = parse_json_object_from_request(request)

required = ['medium', 'address']
Expand Down