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

Commit d0b30d1

Browse files
authored
Allow explicit configuration of OIDC dynamic registration metadata (#12514)
* Fix `element-desktop-ssoid being` included in OIDC Authorization call Signed-off-by: Michael Telatynski <[email protected]> * Split out oidc callback url into its own method Signed-off-by: Michael Telatynski <[email protected]> * Allow explicit configuration of OIDC dynamic registration metadata Signed-off-by: Michael Telatynski <[email protected]> * Fix test Signed-off-by: Michael Telatynski <[email protected]> * Fix unexpected hash on oidc callback url Signed-off-by: Michael Telatynski <[email protected]> * undefined > [] Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 357f882 commit d0b30d1

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

src/BasePlatform.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,23 +430,31 @@ export default abstract class BasePlatform {
430430
return window.location.origin + window.location.pathname;
431431
}
432432

433+
/**
434+
* Fallback Client URI to use for OIDC client registration for if one is not specified in config.json
435+
*/
436+
public get defaultOidcClientUri(): string {
437+
return window.location.origin;
438+
}
439+
433440
/**
434441
* Metadata to use for dynamic OIDC client registrations
435442
*/
436443
public async getOidcClientMetadata(): Promise<OidcRegistrationClientMetadata> {
437444
const config = SdkConfig.get();
438445
return {
439446
clientName: config.brand,
440-
clientUri: this.baseUrl,
447+
clientUri: config.oidc_metadata?.client_uri ?? this.defaultOidcClientUri,
441448
redirectUris: [this.getOidcCallbackUrl().href],
442-
logoUri: new URL("vector-icons/1024.png", this.baseUrl).href,
449+
logoUri: config.oidc_metadata?.logo_uri ?? new URL("vector-icons/1024.png", this.baseUrl).href,
443450
applicationType: "web",
444451
// XXX: We break the spec by not consistently supplying these required fields
445-
// contacts: [],
446452
// @ts-ignore
447-
tosUri: config.terms_and_conditions_links?.[0]?.url,
453+
contacts: config.oidc_metadata?.contacts,
454+
// @ts-ignore
455+
tosUri: config.oidc_metadata?.tos_uri ?? config.terms_and_conditions_links?.[0]?.url,
448456
// @ts-ignore
449-
policyUri: config.privacy_policy_url,
457+
policyUri: config.oidc_metadata?.policy_uri ?? config.privacy_policy_url,
450458
};
451459
}
452460

src/IConfigOptions.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,20 @@ export interface IConfigOptions {
200200
* The issuer URL must have a trailing `/`.
201201
* OPTIONAL
202202
*/
203-
oidc_static_clients?: Record<
204-
string,
205-
{
206-
client_id: string;
207-
}
208-
>;
203+
oidc_static_clients?: {
204+
[issuer: string]: { client_id: string };
205+
};
206+
207+
/**
208+
* Configuration for OIDC dynamic registration where a static OIDC client is not configured.
209+
*/
210+
oidc_metadata?: {
211+
client_uri?: string;
212+
logo_uri?: string;
213+
tos_uri?: string;
214+
policy_uri?: string;
215+
contacts?: string[];
216+
};
209217
}
210218

211219
export interface ISsoRedirectOptions {

test/utils/oidc/registerClient-test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ describe("getOidcClientId()", () => {
4444
return baseUrl;
4545
},
4646
});
47+
Object.defineProperty(PlatformPeg.get(), "defaultOidcClientUri", {
48+
get(): string {
49+
return baseUrl;
50+
},
51+
});
4752
Object.defineProperty(PlatformPeg.get(), "getOidcCallbackUrl", {
4853
value: () => ({
4954
href: baseUrl,

0 commit comments

Comments
 (0)