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

Commit 9646a59

Browse files
dhoffendrichvdh
authored andcommitted
Added possibilty to disable local password authentication (#5092)
Signed-off-by: Daniel Hoffend <[email protected]>
1 parent 457b8e4 commit 9646a59

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

changelog.d/5092.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added possibilty to disable local password authentication. Contributed by Daniel Hoffend.

docs/sample_config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,12 @@ password_config:
10461046
#
10471047
#enabled: false
10481048

1049+
# Uncomment to disable authentication against the local password
1050+
# database. This is ignored if `enabled` is false, and is only useful
1051+
# if you have other password_providers.
1052+
#
1053+
#localdb_enabled: false
1054+
10491055
# Uncomment and change to a secret random string for extra security.
10501056
# DO NOT CHANGE THIS AFTER INITIAL SETUP!
10511057
#

synapse/config/password.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def read_config(self, config, **kwargs):
2626
password_config = {}
2727

2828
self.password_enabled = password_config.get("enabled", True)
29+
self.password_localdb_enabled = password_config.get("localdb_enabled", True)
2930
self.password_pepper = password_config.get("pepper", "")
3031

3132
def generate_config_section(self, config_dir_path, server_name, **kwargs):
@@ -35,6 +36,12 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
3536
#
3637
#enabled: false
3738
39+
# Uncomment to disable authentication against the local password
40+
# database. This is ignored if `enabled` is false, and is only useful
41+
# if you have other password_providers.
42+
#
43+
#localdb_enabled: false
44+
3845
# Uncomment and change to a secret random string for extra security.
3946
# DO NOT CHANGE THIS AFTER INITIAL SETUP!
4047
#

synapse/handlers/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ def validate_login(self, username, login_submission):
743743
result = (result, None)
744744
defer.returnValue(result)
745745

746-
if login_type == LoginType.PASSWORD:
746+
if login_type == LoginType.PASSWORD and self.hs.config.password_localdb_enabled:
747747
known_login_type = True
748748

749749
canonical_user_id = yield self._check_local_password(

synapse/handlers/set_password.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, hs):
3333

3434
@defer.inlineCallbacks
3535
def set_password(self, user_id, newpassword, requester=None):
36+
if not self.hs.config.password_localdb_enabled:
37+
raise SynapseError(403, "Password change disabled", errcode=Codes.FORBIDDEN)
38+
3639
password_hash = yield self._auth_handler.hash(newpassword)
3740

3841
except_device_id = requester.device_id if requester else None

0 commit comments

Comments
 (0)