-
Notifications
You must be signed in to change notification settings - Fork 395
Consolidate SSO redirects through /_matrix/client/v3/login/sso/redirect(/{idpId})
#17972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MadLittleMods
merged 11 commits into
develop
from
madlittlemods/unify-login-sso-redirect
Nov 29, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
91d1b23
Consolidate SSO redirects through `/_matrix/client/v3/login/sso/redir…
MadLittleMods 6276d98
Add changelog
MadLittleMods d0b1552
Fix `tests.rest.client.test_login.MultiSSOTestCase.test_login_via_oidc`
MadLittleMods 4ea1a51
Fix the rest of the `MultiSSOTestCase` tests
MadLittleMods 439aefb
Use better fix
MadLittleMods f97c2f1
Update docstring
MadLittleMods eaad89c
Less clever
MadLittleMods 3c6c0de
Match the surroundings and doesn't need to be public
MadLittleMods feb7e8e
Remove dangling log setup
MadLittleMods be72682
Optional detail in docstring
MadLittleMods a8c8f63
Remove extra newline
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Consolidate SSO redirects through `/_matrix/client/v3/login/sso/redirect(/{idpId})`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# This file is licensed under the Affero General Public License (AGPL) version 3. | ||
# | ||
# Copyright (C) 2024 New Vector, 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 twisted.test.proto_helpers import MemoryReactor | ||
|
||
from synapse.api.urls import LoginSSORedirectURIBuilder | ||
from synapse.server import HomeServer | ||
from synapse.util import Clock | ||
|
||
from tests.unittest import HomeserverTestCase | ||
|
||
# a (valid) url with some annoying characters in. %3D is =, %26 is &, %2B is + | ||
TRICKY_TEST_CLIENT_REDIRECT_URL = 'https://x?<ab c>&q"+%3D%2B"="fö%26=o"' | ||
|
||
|
||
class LoginSSORedirectURIBuilderTestCase(HomeserverTestCase): | ||
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: | ||
self.login_sso_redirect_url_builder = LoginSSORedirectURIBuilder(hs.config) | ||
|
||
def test_no_idp_id(self) -> None: | ||
self.assertEqual( | ||
self.login_sso_redirect_url_builder.build_login_sso_redirect_uri( | ||
idp_id=None, client_redirect_url="http://example.com/redirect" | ||
), | ||
"https://test/_matrix/client/v3/login/sso/redirect?redirectUrl=http%3A%2F%2Fexample.com%2Fredirect", | ||
) | ||
|
||
def test_explicit_idp_id(self) -> None: | ||
self.assertEqual( | ||
self.login_sso_redirect_url_builder.build_login_sso_redirect_uri( | ||
idp_id="oidc-github", client_redirect_url="http://example.com/redirect" | ||
), | ||
"https://test/_matrix/client/v3/login/sso/redirect/oidc-github?redirectUrl=http%3A%2F%2Fexample.com%2Fredirect", | ||
) | ||
|
||
def test_tricky_redirect_uri(self) -> None: | ||
self.assertEqual( | ||
self.login_sso_redirect_url_builder.build_login_sso_redirect_uri( | ||
idp_id="oidc-github", | ||
client_redirect_url=TRICKY_TEST_CLIENT_REDIRECT_URL, | ||
), | ||
"https://test/_matrix/client/v3/login/sso/redirect/oidc-github?redirectUrl=https%3A%2F%2Fx%3F%3Cab+c%3E%26q%22%2B%253D%252B%22%3D%22f%C3%B6%2526%3Do%22", | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.