mirror of
https://github.com/element-hq/synapse.git
synced 2026-09-16 19:12:51 +00:00
This implements the proxying part of [MSC4512](https://github.com/matrix-org/matrix-spec-proposals/pull/4512) and is a stopgap towards https://github.com/element-hq/voip-internal/issues/641. It introduces a new configuration property `io.element.msc4512.proxy` that allows application services to claim namespaces in the C-S and S-S API. For requests underneath a claimed namespace, Synapse first authorizes the request and then reverse-proxies it to the application services. For now, the only allowed namespace that can be claimed is `unstable/io.element.msc4195/rtc/livekit`. This pull request can be reviewed by commits. ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --------- Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
#
|
|
# This file is licensed under the Affero General Public License (AGPL) version 3.
|
|
#
|
|
# Copyright (C) 2026 Element Creations Ltd
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# See the GNU Affero General Public License for more details:
|
|
# <https://www.gnu.org/licenses/agpl-3.0.html>.
|
|
#
|
|
|
|
from synapse.http.appservice_proxy import has_dot_segments
|
|
|
|
from tests import unittest
|
|
|
|
|
|
class HasDotSegmentsTestCase(unittest.TestCase):
|
|
def test_plain_path_has_no_dot_segments(self) -> None:
|
|
self.assertFalse(has_dot_segments(b"/some/path"))
|
|
self.assertFalse(has_dot_segments(b"/some/path.txt"))
|
|
self.assertFalse(has_dot_segments(b"/some/...path"))
|
|
|
|
def test_dot_segment_is_detected(self) -> None:
|
|
self.assertTrue(has_dot_segments(b"/some/./path"))
|
|
self.assertTrue(has_dot_segments(b"/./some/path"))
|
|
self.assertTrue(has_dot_segments(b"/some/path/."))
|
|
|
|
def test_dot_dot_segment_is_detected(self) -> None:
|
|
self.assertTrue(has_dot_segments(b"/some/../path"))
|
|
self.assertTrue(has_dot_segments(b"/../some/path"))
|
|
self.assertTrue(has_dot_segments(b"/some/path/.."))
|
|
|
|
def test_percent_encoded_dot_segments_are_detected(self) -> None:
|
|
self.assertTrue(has_dot_segments(b"/some/%2e%2e/path"))
|
|
self.assertTrue(has_dot_segments(b"/some/%2e/path"))
|
|
self.assertTrue(has_dot_segments(b"/some/%2E%2E/path"))
|
|
|
|
def test_percent_encoded_separator_is_detected(self) -> None:
|
|
self.assertTrue(has_dot_segments(b"/some%2f../path"))
|
|
|
|
def test_double_encoded_dot_segments_are_not_detected(self) -> None:
|
|
# Only a single decode is performed, matching the single decode that route
|
|
# arguments get elsewhere, so a double-encoded segment is left alone.
|
|
self.assertFalse(has_dot_segments(b"/some/%252e%252e/path"))
|