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

Commit 7dbac12

Browse files
authored
Disallow user_consent where experimental MSC3861 is enabled (#16127)
1 parent d6ae404 commit 7dbac12

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

changelog.d/16127.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
User consent features cannot be enabled when using experimental MSC3861.

synapse/config/experimental.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ def check_config_conflicts(self, root: RootConfig) -> None:
173173
("enable_registration",),
174174
)
175175

176+
# We only need to test the user consent version, as if it must be set if the user_consent section was present in the config
177+
if root.consent.user_consent_version is not None:
178+
raise ConfigError(
179+
"User consent cannot be enabled when OAuth delegation is enabled",
180+
("user_consent",),
181+
)
182+
176183
if (
177184
root.oidc.oidc_enabled
178185
or root.saml2.saml2_enabled

tests/config/test_oauth_delegation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
from unittest.mock import Mock
1617

1718
from synapse.config import ConfigError
@@ -167,6 +168,21 @@ def test_registration_cannot_be_enabled(self) -> None:
167168
with self.assertRaises(ConfigError):
168169
self.parse_config()
169170

171+
def test_user_consent_cannot_be_enabled(self) -> None:
172+
tmpdir = self.mktemp()
173+
os.mkdir(tmpdir)
174+
self.config_dict["user_consent"] = {
175+
"require_at_registration": True,
176+
"version": "1",
177+
"template_dir": tmpdir,
178+
"server_notice_content": {
179+
"msgtype": "m.text",
180+
"body": "foo",
181+
},
182+
}
183+
with self.assertRaises(ConfigError):
184+
self.parse_config()
185+
170186
def test_password_config_cannot_be_enabled(self) -> None:
171187
self.config_dict["password_config"] = {"enabled": True}
172188
with self.assertRaises(ConfigError):

0 commit comments

Comments
 (0)