Compare commits

...

8 Commits

Author SHA1 Message Date
Half-Shot
67098ee479 Updated sample config 2019-12-18 10:43:43 +00:00
Will Hunt
16873255f9 Make the words compliant with synapse standards
Co-Authored-By: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2019-12-18 10:43:37 +00:00
Half-Shot
5d3487df84 New sample config 2019-12-18 10:43:30 +00:00
Half-Shot
6861cc1d5a c&p fail 2019-12-18 10:43:23 +00:00
Half-Shot
ce579553db sample config update 2019-12-18 10:43:10 +00:00
Half-Shot
70765be606 linting 2019-12-18 10:43:04 +00:00
Half-Shot
f72b4fe23a newsfile 2019-12-18 10:42:57 +00:00
Half-Shot
14d14e0d49 Port https://github.com/matrix-org/synapse-dinsic/pull/18 2019-12-18 10:42:50 +00:00
5 changed files with 28 additions and 1 deletions

1
changelog.d/6523.feature Normal file
View File

@@ -0,0 +1 @@
Add option `limit_profile_requests_to_users_who_share_rooms` to prevent requirement of a local user sharing a room with another user to query their profile information.

View File

@@ -54,6 +54,13 @@ pid_file: DATADIR/homeserver.pid
# #
#require_auth_for_profile_requests: true #require_auth_for_profile_requests: true
# Uncomment to require a user to share a room with another user in order
# to retrieve their profile information. Only checked on Client-Server
# requests. Profile requests from other servers should be checked by the
# requesting server. Defaults to 'false'.
#
#limit_profile_requests_to_users_who_share_rooms: true
# If set to 'true', removes the need for authentication to access the server's # If set to 'true', removes the need for authentication to access the server's
# public rooms directory through the client API, meaning that anyone can # public rooms directory through the client API, meaning that anyone can
# query the room directory. Defaults to 'false'. # query the room directory. Defaults to 'false'.

View File

@@ -102,6 +102,12 @@ class ServerConfig(Config):
"require_auth_for_profile_requests", False "require_auth_for_profile_requests", False
) )
# Whether to require sharing a room with a user to retrieve their
# profile data
self.limit_profile_requests_to_users_who_share_rooms = config.get(
"limit_profile_requests_to_users_who_share_rooms", False,
)
if "restrict_public_rooms_to_local_users" in config and ( if "restrict_public_rooms_to_local_users" in config and (
"allow_public_rooms_without_auth" in config "allow_public_rooms_without_auth" in config
or "allow_public_rooms_over_federation" in config or "allow_public_rooms_over_federation" in config
@@ -621,6 +627,13 @@ class ServerConfig(Config):
# #
#require_auth_for_profile_requests: true #require_auth_for_profile_requests: true
# Uncomment to require a user to share a room with another user in order
# to retrieve their profile information. Only checked on Client-Server
# requests. Profile requests from other servers should be checked by the
# requesting server. Defaults to 'false'.
#
#limit_profile_requests_to_users_who_share_rooms: true
# If set to 'true', removes the need for authentication to access the server's # If set to 'true', removes the need for authentication to access the server's
# public rooms directory through the client API, meaning that anyone can # public rooms directory through the client API, meaning that anyone can
# query the room directory. Defaults to 'false'. # query the room directory. Defaults to 'false'.

View File

@@ -295,12 +295,16 @@ class BaseProfileHandler(BaseHandler):
be found to be in any room the server is in, and therefore the query be found to be in any room the server is in, and therefore the query
is denied. is denied.
""" """
# Implementation of MSC1301: don't allow looking up profiles if the # Implementation of MSC1301: don't allow looking up profiles if the
# requester isn't in the same room as the target. We expect requester to # requester isn't in the same room as the target. We expect requester to
# be None when this function is called outside of a profile query, e.g. # be None when this function is called outside of a profile query, e.g.
# when building a membership event. In this case, we must allow the # when building a membership event. In this case, we must allow the
# lookup. # lookup.
if not self.hs.config.require_auth_for_profile_requests or not requester: if (
not self.hs.config.limit_profile_requests_to_users_who_share_rooms
or not requester
):
return return
# Always allow the user to query their own profile. # Always allow the user to query their own profile.

View File

@@ -237,6 +237,7 @@ class ProfilesRestrictedTestCase(unittest.HomeserverTestCase):
config = self.default_config() config = self.default_config()
config["require_auth_for_profile_requests"] = True config["require_auth_for_profile_requests"] = True
config["limit_profile_requests_to_users_who_share_rooms"] = True
self.hs = self.setup_test_homeserver(config=config) self.hs = self.setup_test_homeserver(config=config)
return self.hs return self.hs
@@ -309,6 +310,7 @@ class OwnProfileUnrestrictedTestCase(unittest.HomeserverTestCase):
def make_homeserver(self, reactor, clock): def make_homeserver(self, reactor, clock):
config = self.default_config() config = self.default_config()
config["require_auth_for_profile_requests"] = True config["require_auth_for_profile_requests"] = True
config["limit_profile_requests_to_users_who_share_rooms"] = True
self.hs = self.setup_test_homeserver(config=config) self.hs = self.setup_test_homeserver(config=config)
return self.hs return self.hs