From 65e0961a18da93cb9e1aaf1527f316e149a10cec Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Mon, 31 Oct 2022 13:20:15 +0000 Subject: [PATCH] [AAE-10835] adf-cli Being able to pass params as input to handle custom cases (#7880) * Being able to pass params as input to handle hxp * Fix default * Fix lint * Use a default value for tokenEndpoint for compatibility * Fix the lint --- lib/cli/scripts/init-aae-env.ts | 49 +++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/lib/cli/scripts/init-aae-env.ts b/lib/cli/scripts/init-aae-env.ts index 1d14262042..d37ad023fe 100644 --- a/lib/cli/scripts/init-aae-env.ts +++ b/lib/cli/scripts/init-aae-env.ts @@ -35,10 +35,12 @@ export interface ConfigArgs { modelerPassword: string; devopsUsername: string; devopsPassword: string; - clientId: string; - host: string; oauth: string; - identityHost: boolean; + tokenEndpoint: string; + clientId: string; + secret: string; + scope: string; + host: string; tag: string; } @@ -267,6 +269,11 @@ function deploy(model: any) { } } +function initializeDefaultToken(options) { + options.tokenEndpoint = options.tokenEndpoint.replace('${clientId}', options.clientId); + return options; +} + function getAlfrescoJsApiInstance(configArgs: ConfigArgs) { let ssoHost = configArgs.oauth; ssoHost = ssoHost ?? configArgs.host; @@ -275,11 +282,12 @@ function getAlfrescoJsApiInstance(configArgs: ConfigArgs) { provider: 'BPM', hostBpm: `${configArgs.host}`, authType: 'OAUTH', - oauth2: { - host: `${ssoHost}/auth/realms/alfresco`, + oauth2 : { + host: `${ssoHost}`, + tokenUrl: `${ssoHost}/${configArgs.tokenEndpoint}`, clientId: `${configArgs.clientId}`, - scope: 'openid', - secret: '', + scope: `${configArgs.scope}`, + secret: `${configArgs.secret}`, implicitFlow: false, silentLogin: false, redirectUri: '/' @@ -454,13 +462,11 @@ async function sleep(time: number) { return; } -export default async function(configArgs: ConfigArgs) { - await main(configArgs); +export default async function() { + await main(); } -async function main(configArgs: ConfigArgs) { - args = configArgs; - +async function main() { program .version('0.1.0') .description('The following command is in charge of Initializing the activiti cloud env with the default apps' + @@ -468,6 +474,9 @@ async function main(configArgs: ConfigArgs) { .option('-h, --host [type]', 'Host gateway') .option('--oauth [type]', 'SSO host') .option('--clientId [type]', 'sso client') + .option('--secret [type]', 'sso secret', '') + .option('--scope [type]', 'sso scope', 'openid') + .option('--tokenEndpoint [type]', 'discovery token Endpoint', 'auth/realms/${clientId}/protocol/openid-connect/token') .option('--modelerUsername [type]', 'username of a user with role ACTIVIT_MODELER') .option('--modelerPassword [type]', 'modeler password') .option('--devopsUsername [type]', 'username of a user with role ACTIVIT_DEVOPS') @@ -480,6 +489,22 @@ async function main(configArgs: ConfigArgs) { return; } + const options = initializeDefaultToken(program.opts()); + + args = { + host: options.host, + clientId: options.clientId, + devopsUsername: options.devopsUsername, + devopsPassword: options.devopsPassword, + modelerUsername: options.modelerUsername, + modelerPassword: options.modelerPassword, + oauth: options.oauth, + tokenEndpoint: options.tokenEndpoint, + scope: options.scope, + secret: options.secret, + tag: options.tag + }; + alfrescoJsApiModeler = getAlfrescoJsApiInstance(args); AAE_MICROSERVICES.map(async (serviceName) => {