summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorJacek KuĊ›nierz <jacek.kusnierz@tum.de>2022-06-16 12:48:18 +0200
committerGitHub <noreply@github.com>2022-06-16 11:48:18 +0100
commit0ef1307619799bec2bbb96ce6516f307b0f8f217 (patch)
treedfbaaad6bfb22e0244733df8e538bcc6b8d5d660 /synapse
parentAdd instructions for running Complement with `gotestfmt`-formatted output loc... (diff)
downloadsynapse-0ef1307619799bec2bbb96ce6516f307b0f8f217.tar.xz
Add custom well-known (#13035)
Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
Diffstat (limited to 'synapse')
-rw-r--r--synapse/config/server.py20
-rw-r--r--synapse/rest/well_known.py9
2 files changed, 28 insertions, 1 deletions
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 828938e5ec..085fe22c51 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -301,6 +301,26 @@ class ServerConfig(Config):
                 "public_baseurl cannot contain query parameters or a #-fragment"
             )
 
+        self.extra_well_known_client_content = config.get(
+            "extra_well_known_client_content", {}
+        )
+
+        if not isinstance(self.extra_well_known_client_content, dict):
+            raise ConfigError(
+                "extra_well_known_content must be a dictionary of key-value pairs"
+            )
+
+        if "m.homeserver" in self.extra_well_known_client_content:
+            raise ConfigError(
+                "m.homeserver is not supported in extra_well_known_content, "
+                "use public_baseurl in base config instead."
+            )
+        if "m.identity_server" in self.extra_well_known_client_content:
+            raise ConfigError(
+                "m.identity_server is not supported in extra_well_known_content, "
+                "use default_identity_server in base config instead."
+            )
+
         # Whether to enable user presence.
         presence_config = config.get("presence") or {}
         self.use_presence = presence_config.get("enabled")
diff --git a/synapse/rest/well_known.py b/synapse/rest/well_known.py
index 04b035a1b1..6f7ac54c65 100644
--- a/synapse/rest/well_known.py
+++ b/synapse/rest/well_known.py
@@ -11,7 +11,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 import logging
 from typing import TYPE_CHECKING, Optional
 
@@ -44,6 +43,14 @@ class WellKnownBuilder:
                 "base_url": self._config.registration.default_identity_server
             }
 
+        if self._config.server.extra_well_known_client_content:
+            for (
+                key,
+                value,
+            ) in self._config.server.extra_well_known_client_content.items():
+                if key not in result:
+                    result[key] = value
+
         return result