diff options
author | Erik Johnston <erikj@jki.re> | 2018-10-25 17:04:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 17:04:59 +0100 |
commit | c85e063302243d2c82da6e709cf1e93b5b3085e9 (patch) | |
tree | 05bde2fb78f07141bda83d0a4fa54f08c19ec55c /synapse/handlers/directory.py | |
parent | Merge pull request #4081 from matrix-org/neilj/fix_mau_init (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/alias_disa... (diff) | |
download | synapse-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.py | 9 |
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 |