Add ?no_universal_links=true to OIDC url so EX doesn't try to handle it (#29439)
* Add `?no_universal_links=true` to OIDC cb url so EX doesn't try to handle it This is specific to macOS and only affects cases where auth is attempted in the non-default browser Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Strip no_universal_links after auth Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update MAS Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update playwright-common Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Bump @element-hq/element-web-playwright-common Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -477,6 +477,8 @@ export default abstract class BasePlatform {
|
|||||||
// The redirect URL has to exactly match that registered at the OIDC server, so
|
// The redirect URL has to exactly match that registered at the OIDC server, so
|
||||||
// ensure that the fragment part of the URL is empty.
|
// ensure that the fragment part of the URL is empty.
|
||||||
url.hash = "";
|
url.hash = "";
|
||||||
|
// Set no_universal_links=true to prevent the callback being handled by Element X installed on macOS Apple Silicon
|
||||||
|
url.searchParams.set("no_universal_links", "true");
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ function onTokenLoginCompleted(): void {
|
|||||||
// a little nasty but let's redirect to clear them.
|
// a little nasty but let's redirect to clear them.
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
|
|
||||||
|
url.searchParams.delete("no_universal_links");
|
||||||
url.searchParams.delete("loginToken");
|
url.searchParams.delete("loginToken");
|
||||||
url.searchParams.delete("state");
|
url.searchParams.delete("state");
|
||||||
url.searchParams.delete("code");
|
url.searchParams.delete("code");
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* @jest-environment jsdom
|
||||||
|
* @jest-environment-options {"url": "https://app.element.io/?loginToken=123&state=abc&code=xyz&no_universal_links&something_else=value"}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2024 New Vector Ltd.
|
Copyright 2024 New Vector Ltd.
|
||||||
|
|
||||||
@@ -42,11 +47,27 @@ describe("showError", () => {
|
|||||||
describe("loadApp", () => {
|
describe("loadApp", () => {
|
||||||
beforeEach(setUpMatrixChatDiv);
|
beforeEach(setUpMatrixChatDiv);
|
||||||
|
|
||||||
it("should set window.matrixChat to the MatrixChat instance", async () => {
|
beforeEach(async () => {
|
||||||
fetchMock.get("https://matrix.org/_matrix/client/versions", { versions: ["v1.6"] });
|
fetchMock.get("https://matrix.org/_matrix/client/versions", { versions: ["v1.6"] });
|
||||||
SdkConfig.put({ default_server_config: { "m.homeserver": { base_url: "https://matrix.org" } } });
|
SdkConfig.put({ default_server_config: { "m.homeserver": { base_url: "https://matrix.org" } } });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set window.matrixChat to the MatrixChat instance", async () => {
|
||||||
await loadApp({});
|
await loadApp({});
|
||||||
await waitFor(() => expect(window.matrixChat).toBeInstanceOf(MatrixChat));
|
await waitFor(() => expect(window.matrixChat).toBeInstanceOf(MatrixChat));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should pass onTokenLoginCompleted which strips searchParams to MatrixChat", async () => {
|
||||||
|
const spy = jest.spyOn(window.history, "replaceState");
|
||||||
|
|
||||||
|
await loadApp({});
|
||||||
|
await waitFor(() => expect(window.matrixChat).toBeInstanceOf(MatrixChat));
|
||||||
|
window.matrixChat!.props.onTokenLoginCompleted();
|
||||||
|
|
||||||
|
expect(spy).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
"",
|
||||||
|
expect.stringContaining("https://app.element.io/?something_else=value"),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user