Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
e5481b22
Commit
e5481b22
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Use allow/deny
parent
47a9ba43
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/config/room_directory.py
+6
-6
6 additions, 6 deletions
synapse/config/room_directory.py
tests/config/test_room_directory.py
+4
-4
4 additions, 4 deletions
tests/config/test_room_directory.py
tests/handlers/test_directory.py
+1
-1
1 addition, 1 deletion
tests/handlers/test_directory.py
with
11 additions
and
11 deletions
synapse/config/room_directory.py
+
6
−
6
View file @
e5481b22
...
...
@@ -35,13 +35,13 @@ class RoomDirectoryConfig(Config):
# 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
"
allow
ed
"
or
"
den
ied
"
.
# currently either be
"
allow
"
or
"
den
y
"
.
#
# If no rules match the request is denied.
alias_creation_rules:
- user_id:
"
*
"
alias:
"
*
"
action: allow
ed
action: allow
"""
def
is_alias_creation_allowed
(
self
,
user_id
,
alias
):
...
...
@@ -56,7 +56,7 @@ class RoomDirectoryConfig(Config):
"""
for
rule
in
self
.
_alias_creation_rules
:
if
rule
.
matches
(
user_id
,
alias
):
return
rule
.
action
==
"
allow
ed
"
return
rule
.
action
==
"
allow
"
return
False
...
...
@@ -67,12 +67,12 @@ class _AliasRule(object):
user_id
=
rule
[
"
user_id
"
]
alias
=
rule
[
"
alias
"
]
if
action
in
(
"
allow
ed
"
,
"
den
ied
"
):
if
action
in
(
"
allow
"
,
"
den
y
"
):
self
.
action
=
action
else
:
raise
ConfigError
(
"
alias_creation_rules rules can only have action of
'
allow
ed
'"
"
or
'
den
ied
'"
"
alias_creation_rules rules can only have action of
'
allow
'"
"
or
'
den
y
'"
)
try
:
...
...
This diff is collapsed.
Click to expand it.
tests/config/test_room_directory.py
+
4
−
4
View file @
e5481b22
...
...
@@ -26,16 +26,16 @@ class RoomDirectoryConfigTestCase(unittest.TestCase):
alias_creation_rules:
- user_id:
"
*bob*
"
alias:
"
*
"
action:
"
den
ied
"
action:
"
den
y
"
- user_id:
"
*
"
alias:
"
#unofficial_*
"
action:
"
allow
ed
"
action:
"
allow
"
- user_id:
"
@foo*:example.com
"
alias:
"
*
"
action:
"
allow
ed
"
action:
"
allow
"
- user_id:
"
@gah:example.com
"
alias:
"
#goo:example.com
"
action:
"
allow
ed
"
action:
"
allow
"
"""
)
rd_config
=
RoomDirectoryConfig
()
...
...
This diff is collapsed.
Click to expand it.
tests/handlers/test_directory.py
+
1
−
1
View file @
e5481b22
...
...
@@ -118,7 +118,7 @@ class TestCreateAliasACL(unittest.HomeserverTestCase):
{
"
user_id
"
:
"
*
"
,
"
alias
"
:
"
#unofficial_*
"
,
"
action
"
:
"
allow
ed
"
,
"
action
"
:
"
allow
"
,
}
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment