mirror of
https://github.com/element-hq/element-web
synced 2024-11-26 11:15:53 +03:00
Split out oidc callback url into its own method
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
b82100ede8
commit
9efa04da7a
1 changed files with 15 additions and 8 deletions
|
@ -57,6 +57,8 @@ interface SquirrelUpdate {
|
|||
updateURL: string;
|
||||
}
|
||||
|
||||
const LEGACY_PROTOCOL = "element";
|
||||
const OIDC_PROTOCOL = "io.element.desktop";
|
||||
const SSO_ID_KEY = "element-desktop-ssoid";
|
||||
|
||||
const isMac = navigator.platform.toUpperCase().includes("MAC");
|
||||
|
@ -377,12 +379,10 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
return this.ipc.call("getAvailableSpellCheckLanguages");
|
||||
}
|
||||
|
||||
public getSSOCallbackUrl(forOidc = false, fragmentAfterLogin?: string): URL {
|
||||
const url = super.getSSOCallbackUrl(forOidc, fragmentAfterLogin);
|
||||
url.protocol = "element";
|
||||
if (!forOidc) {
|
||||
public getSSOCallbackUrl(fragmentAfterLogin?: string): URL {
|
||||
const url = super.getSSOCallbackUrl(fragmentAfterLogin);
|
||||
url.protocol = LEGACY_PROTOCOL;
|
||||
url.searchParams.set(SSO_ID_KEY, this.ssoID);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
@ -448,11 +448,9 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
|
||||
public async getOidcClientMetadata(): Promise<OidcRegistrationClientMetadata> {
|
||||
const baseMetadata = await super.getOidcClientMetadata();
|
||||
const redirectUri = this.getSSOCallbackUrl(true);
|
||||
return {
|
||||
...baseMetadata,
|
||||
applicationType: "native",
|
||||
redirectUris: [redirectUri.href],
|
||||
// XXX: This should be overridable in config
|
||||
clientUri: "https://element.io",
|
||||
};
|
||||
|
@ -461,4 +459,13 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
public getOidcClientState(): string {
|
||||
return `:${SSO_ID_KEY}:${this.ssoID}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL to return to after a successful OIDC authentication
|
||||
*/
|
||||
public getOidcCallbackUrl(): URL {
|
||||
const url = super.getOidcCallbackUrl();
|
||||
url.protocol = OIDC_PROTOCOL;
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue