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

Commit

Permalink
Disallow user_consent where experimental MSC3861 is enabled (#16127)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns authored Aug 22, 2023
1 parent d6ae404 commit 7dbac12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/16127.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
User consent features cannot be enabled when using experimental MSC3861.
7 changes: 7 additions & 0 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ def check_config_conflicts(self, root: RootConfig) -> None:
("enable_registration",),
)

# 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
if root.consent.user_consent_version is not None:
raise ConfigError(
"User consent cannot be enabled when OAuth delegation is enabled",
("user_consent",),
)

if (
root.oidc.oidc_enabled
or root.saml2.saml2_enabled
Expand Down
16 changes: 16 additions & 0 deletions tests/config/test_oauth_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from unittest.mock import Mock

from synapse.config import ConfigError
Expand Down Expand Up @@ -167,6 +168,21 @@ def test_registration_cannot_be_enabled(self) -> None:
with self.assertRaises(ConfigError):
self.parse_config()

def test_user_consent_cannot_be_enabled(self) -> None:
tmpdir = self.mktemp()
os.mkdir(tmpdir)
self.config_dict["user_consent"] = {
"require_at_registration": True,
"version": "1",
"template_dir": tmpdir,
"server_notice_content": {
"msgtype": "m.text",
"body": "foo",
},
}
with self.assertRaises(ConfigError):
self.parse_config()

def test_password_config_cannot_be_enabled(self) -> None:
self.config_dict["password_config"] = {"enabled": True}
with self.assertRaises(ConfigError):
Expand Down

0 comments on commit 7dbac12

Please sign in to comment.