Skip to content

Commit

Permalink
Use allow/deny
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Oct 25, 2018
1 parent 47a9ba4 commit e5481b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions synapse/config/room_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def default_config(self, config_dir_path, server_name, **kwargs):
# The format of this option is a list of rules that contain globs that
# match against user_id and the new alias (fully qualified with server
# name). The action in the first rule that matches is taken, which can
# currently either be "allowed" or "denied".
# currently either be "allow" or "deny".
#
# If no rules match the request is denied.
alias_creation_rules:
- user_id: "*"
alias: "*"
action: allowed
action: allow
"""

def is_alias_creation_allowed(self, user_id, alias):
Expand All @@ -56,7 +56,7 @@ def is_alias_creation_allowed(self, user_id, alias):
"""
for rule in self._alias_creation_rules:
if rule.matches(user_id, alias):
return rule.action == "allowed"
return rule.action == "allow"

return False

Expand All @@ -67,12 +67,12 @@ def __init__(self, rule):
user_id = rule["user_id"]
alias = rule["alias"]

if action in ("allowed", "denied"):
if action in ("allow", "deny"):
self.action = action
else:
raise ConfigError(
"alias_creation_rules rules can only have action of 'allowed'"
" or 'denied'"
"alias_creation_rules rules can only have action of 'allow'"
" or 'deny'"
)

try:
Expand Down
8 changes: 4 additions & 4 deletions tests/config/test_room_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def test_alias_creation_acl(self):
alias_creation_rules:
- user_id: "*bob*"
alias: "*"
action: "denied"
action: "deny"
- user_id: "*"
alias: "#unofficial_*"
action: "allowed"
action: "allow"
- user_id: "@foo*:example.com"
alias: "*"
action: "allowed"
action: "allow"
- user_id: "@gah:example.com"
alias: "#goo:example.com"
action: "allowed"
action: "allow"
""")

rd_config = RoomDirectoryConfig()
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def prepare(self, hs, reactor, clock):
{
"user_id": "*",
"alias": "#unofficial_*",
"action": "allowed",
"action": "allow",
}
]

Expand Down

0 comments on commit e5481b2

Please sign in to comment.