From 3a2954d3b2eceae84422e6ea014f87a4a9c92144 Mon Sep 17 00:00:00 2001 From: Norbert Nagy Date: Tue, 2 Jul 2024 16:39:13 +0300 Subject: [PATCH] feat(cli): seed multiple redurect uris (#58) --- .../cli/src/commands/database/ogcio/applications.ts | 10 +++++++++- .../cli/src/commands/database/ogcio/ogcio-seeder.ts | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/database/ogcio/applications.ts b/packages/cli/src/commands/database/ogcio/applications.ts index 3ec1455b7da..1027c92ba97 100644 --- a/packages/cli/src/commands/database/ogcio/applications.ts +++ b/packages/cli/src/commands/database/ogcio/applications.ts @@ -41,6 +41,14 @@ const setApplicationId = async ( element = await createApplication(transaction, tenantId, element); }; +const createArrayString = (values: string | string[]): string => { + const valuesString = (Array.isArray(values) ? values : [values]) + .map((uri) => `"${uri}"`) + .join(','); + + return `[${valuesString}]`; +}; + const fillApplications = ( inputApplications: ApplicationSeeder[] ): Record => { @@ -52,7 +60,7 @@ const fillApplications = ( secret: inputApp.secret, description: inputApp.description, type: inputApp.type, - oidc_client_metadata: `{"redirectUris": ["${inputApp.redirect_uri}"], "postLogoutRedirectUris": ["${inputApp.logout_redirect_uri}"]}`, + oidc_client_metadata: `{"redirectUris": ${createArrayString(inputApp.redirect_uri)}, "postLogoutRedirectUris": ${createArrayString(inputApp.logout_redirect_uri)}}`, custom_client_metadata: '{"idTokenTtl": 3600, "corsAllowedOrigins": [], "rotateRefreshToken": true, "refreshTokenTtlInDays": 14, "alwaysIssueRefreshToken": false}', is_third_party: inputApp.is_third_party ?? false, diff --git a/packages/cli/src/commands/database/ogcio/ogcio-seeder.ts b/packages/cli/src/commands/database/ogcio/ogcio-seeder.ts index 7b34775aebd..fb976d82c07 100644 --- a/packages/cli/src/commands/database/ogcio/ogcio-seeder.ts +++ b/packages/cli/src/commands/database/ogcio/ogcio-seeder.ts @@ -36,8 +36,8 @@ export type ApplicationSeeder = { name: string; description: string; type: string; - redirect_uri: string; - logout_redirect_uri: string; + redirect_uri: string | string[]; + logout_redirect_uri: string | string[]; id: string; secret: string; is_third_party?: boolean;