summary refs log tree commit diff
path: root/synapse/handlers/directory.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-10-25 17:04:59 +0100
committerGitHub <noreply@github.com>2018-10-25 17:04:59 +0100
commitc85e063302243d2c82da6e709cf1e93b5b3085e9 (patch)
tree05bde2fb78f07141bda83d0a4fa54f08c19ec55c /synapse/handlers/directory.py
parentMerge pull request #4081 from matrix-org/neilj/fix_mau_init (diff)
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/alias_disa... (diff)
downloadsynapse-c85e063302243d2c82da6e709cf1e93b5b3085e9.tar.xz
Merge pull request #4051 from matrix-org/erikj/alias_disallow_list
Add config option to control alias creation
Diffstat (limited to 'synapse/handlers/directory.py')
-rw-r--r--synapse/handlers/directory.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 02f12f6645..7d67bf803a 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -43,6 +43,7 @@ class DirectoryHandler(BaseHandler):
         self.state = hs.get_state_handler()
         self.appservice_handler = hs.get_application_service_handler()
         self.event_creation_handler = hs.get_event_creation_handler()
+        self.config = hs.config
 
         self.federation = hs.get_federation_client()
         hs.get_federation_registry().register_query_handler(
@@ -111,6 +112,14 @@ class DirectoryHandler(BaseHandler):
                     403, "This user is not permitted to create this alias",
                 )
 
+            if not self.config.is_alias_creation_allowed(user_id, room_alias.to_string()):
+                # Lets just return a generic message, as there may be all sorts of
+                # reasons why we said no. TODO: Allow configurable error messages
+                # per alias creation rule?
+                raise SynapseError(
+                    403, "Not allowed to create alias",
+                )
+
             can_create = yield self.can_modify_alias(
                 room_alias,
                 user_id=user_id