From 80c68cfab27ca01ab0b22fdf6e51d6ec876cc503 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 17 Sep 2020 12:37:15 -0400 Subject: [PATCH 1/3] Add flags about whether new rooms are encrypted by default based on configuration. --- synapse/rest/client/versions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 24ac57f35d8a..5f713e04903c 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -19,6 +19,7 @@ import logging import re +from synapse.api.constants import RoomCreationPreset from synapse.http.servlet import RestServlet logger = logging.getLogger(__name__) @@ -31,6 +32,18 @@ def __init__(self, hs): super(VersionsRestServlet, self).__init__() self.config = hs.config + # Calculate these once since they shouldn't change after start-up. + self.e2ee_forced_public = ( + RoomCreationPreset.PUBLIC_CHAT + in self.config.encryption_enabled_by_default_for_room_presets + ) + self.e2ee_forced_private = ( + RoomCreationPreset.PRIVATE_CHAT + in self.config.encryption_enabled_by_default_for_room_presets + or RoomCreationPreset.TRUSTED_PRIVATE_CHAT + in self.config.encryption_enabled_by_default_for_room_presets + ) + def on_GET(self, request): return ( 200, @@ -62,6 +75,9 @@ def on_GET(self, request): "org.matrix.msc2432": True, # Implements additional endpoints as described in MSC2666 "uk.half-shot.msc2666": True, + # Whether the new rooms will be set to encrypted or not. + "io.element.e2ee_forced.public": self.e2ee_forced_public, + "io.element.e2ee_forced.private": self.e2ee_forced_private, }, }, ) From 6761768700f83ec8697b33da1c1cc9961dd960ad Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 17 Sep 2020 12:45:11 -0400 Subject: [PATCH 2/3] Add a changelog. --- changelog.d/8343.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8343.feature diff --git a/changelog.d/8343.feature b/changelog.d/8343.feature new file mode 100644 index 000000000000..ccecb22f37f4 --- /dev/null +++ b/changelog.d/8343.feature @@ -0,0 +1 @@ +Add flags to the `/versions` endpoint that includes whether new rooms default to using E2EE. From aa9893ce4497438fd2cfc8e7bcdf343f84004371 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 17 Sep 2020 16:37:05 -0400 Subject: [PATCH 3/3] Separate trusted_private to a separate variable. --- synapse/rest/client/versions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 5f713e04903c..c560edbc590e 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -40,7 +40,9 @@ def __init__(self, hs): self.e2ee_forced_private = ( RoomCreationPreset.PRIVATE_CHAT in self.config.encryption_enabled_by_default_for_room_presets - or RoomCreationPreset.TRUSTED_PRIVATE_CHAT + ) + self.e2ee_forced_trusted_private = ( + RoomCreationPreset.TRUSTED_PRIVATE_CHAT in self.config.encryption_enabled_by_default_for_room_presets ) @@ -75,9 +77,10 @@ def on_GET(self, request): "org.matrix.msc2432": True, # Implements additional endpoints as described in MSC2666 "uk.half-shot.msc2666": True, - # Whether the new rooms will be set to encrypted or not. + # Whether new rooms will be set to encrypted or not (based on presets). "io.element.e2ee_forced.public": self.e2ee_forced_public, "io.element.e2ee_forced.private": self.e2ee_forced_private, + "io.element.e2ee_forced.trusted_private": self.e2ee_forced_trusted_private, }, }, )