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

Commit 54fe012

Browse files
committed
Fix advertised flows when SSO is not in use
1 parent 97e4775 commit 54fe012

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

synapse/rest/client/login.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
148148
# to SSO.
149149
flows.append({"type": LoginRestServlet.CAS_TYPE})
150150

151-
if (
152-
self.cas_enabled
153-
or self.saml2_enabled
154-
or self.oidc_enabled
155-
or self._get_login_token_enabled
156-
):
151+
# MSC3882 requires m.login.token to be advertised
152+
supportLoginTokenFlow = self._get_login_token_enabled
153+
154+
if self.cas_enabled or self.saml2_enabled or self.oidc_enabled:
157155
flows.append(
158156
{
159157
"type": LoginRestServlet.SSO_TYPE,
@@ -164,13 +162,10 @@ def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
164162
}
165163
)
166164

167-
# While it's valid for us to advertise this login type generally,
168-
# synapse currently only gives out these tokens as part of the
169-
# SSO login flow.
170-
# Generally we don't want to advertise login flows that clients
171-
# don't know how to implement, since they (currently) will always
172-
# fall back to the fallback API if they don't understand one of the
173-
# login flow types returned.
165+
# SSO requires a login token to be generated, so we need to advertise that flow
166+
supportLoginTokenFlow = True
167+
168+
if supportLoginTokenFlow:
174169
tokenTypeFlow: Dict[str, Any] = {"type": LoginRestServlet.TOKEN_TYPE}
175170
# If MSC3882 is enabled we advertise the get_login_token flag.
176171
if self._get_login_token_enabled:

tests/rest/client/test_login.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,14 @@ def test_get_login_flows_with_msc3882_enabled(self) -> None:
464464
channel = self.make_request("GET", "/_matrix/client/r0/login")
465465
self.assertEqual(channel.code, 200, channel.result)
466466

467-
print(channel.json_body)
468-
469-
flows = {flow["type"]: flow for flow in channel.json_body["flows"]}
470-
self.assertTrue(flows["m.login.token"]["org.matrix.msc3882.get_login_token"])
467+
self.assertCountEqual(
468+
channel.json_body["flows"],
469+
[
470+
{"type": "m.login.token", "org.matrix.msc3882.get_login_token": True},
471+
{"type": "m.login.password"},
472+
{"type": "m.login.application_service"},
473+
],
474+
)
471475

472476

473477
@skip_unless(has_saml2 and HAS_OIDC, "Requires SAML2 and OIDC")

0 commit comments

Comments
 (0)