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

Add require_auth_for_room_directory option #2421

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def read_config(self, config):

self.filter_timeline_limit = config.get("filter_timeline_limit", -1)

self.require_auth_for_room_directory = \
config.get("require_auth_for_room_directory", False)

if self.public_baseurl is not None:
if self.public_baseurl[-1] != '/':
self.public_baseurl += '/'
Expand Down Expand Up @@ -194,6 +197,11 @@ def default_config(self, server_name, **kwargs):
# and sync operations. The default value is -1, means no upper limit.
# filter_timeline_limit: 5000

# Set whether this server's public room directory is restricted to
# local authenticated users, or visible to the wider world.
# Default is to be visible to the wider world.
require_auth_for_room_directory: False

# List of ports that Synapse should listen on, their purpose and their
# configuration.
listeners:
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v1/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def on_GET(self, request):
# In both cases we call the auth function, as that has the side
# effect of logging who issued this request if an access token was
# provided.
if server:
if server or self.hs.config.require_auth_for_room_directory:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the wrong place for this check. Specifically, it blocks local users from requesting the directory from remote servers. It does nothing to stop users on remote servers from requesting our directory, which uses a different endpoint, and is what I think you're after.

Try here:

def on_GET(self, origin, content, query):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, we probably need both checks.

raise e
else:
pass
Expand Down