@docupace/pipeline 1.0.1-2.ervins.7 → 1.0.1-2.ervinsUpdate2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.12.ervins.7",
3
+ "version": "1.0.12.ervinsUpdate2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/auth0/cli.js CHANGED
@@ -15,10 +15,10 @@ dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
15
15
  const program = new Command();
16
16
 
17
17
  program
18
- .command('configureFromSite <fromSite> <toSite> <env> <deployUI> <deployGraphQLServer> <useNewDomain>')
18
+ .command('configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain>')
19
19
  .description('Configure the Auth0 tenants in env for the given site')
20
- .action(async (fromSite, toSite, env, deployUI, deployGraphQLServer, useNewDomain) => {
21
- await configureFromSite(fromSite, toSite, env, deployUI, deployGraphQLServer, useNewDomain);
20
+ .action(async (fromSite, toSite, fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain) => {
21
+ await configureFromSite(fromSite, toSite, fromEnv, toEnv, deployUI, deployGraphQLServer, useNewDomain);
22
22
  });
23
23
 
24
24
  program
@@ -169,6 +169,11 @@ async function templateAuth0(siteUrl, coreApiContext, env, filePaths, deployUI,
169
169
 
170
170
  graphqlAllowedCallbacksUrls = [`${siteUrl}/api/graphql/callback`];
171
171
  graphqlAllowedLogoutUrls = [`${siteUrl}/api/graphql/`];
172
+
173
+ connectAllowedCallbacksUrls = [`${siteUrl}/connect/samlCallback?client_name=auth0`];
174
+ connectlAllowedLogoutUrls = [ `${siteUrl}/connect`];
175
+
176
+
172
177
  } else {
173
178
  uiAllowedCallbacksUrls = [
174
179
  `${siteUrl}/api/auth/callback`,
@@ -187,6 +192,16 @@ async function templateAuth0(siteUrl, coreApiContext, env, filePaths, deployUI,
187
192
  `http://localhost:4000/api/graphql/`,
188
193
  `${siteUrl}/api/graphql/`,
189
194
  ];
195
+
196
+ connectAllowedCallbacksUrls = [
197
+ `${siteUrl}/connect/samlCallback?client_name=auth0`,
198
+ `http://localhost:9000/connect/samlCallback?client_name=auth0`,
199
+ ];
200
+ connectlAllowedLogoutUrls = [
201
+ `${siteUrl}/connect`
202
+ ];
203
+
204
+
190
205
  }
191
206
 
192
207
  const configureUI = deployUI === 'true';
@@ -198,6 +213,16 @@ async function templateAuth0(siteUrl, coreApiContext, env, filePaths, deployUI,
198
213
  callbacks: uiAllowedCallbacksUrls,
199
214
  allowed_logout_urls: uiAllowedLogoutUrls,
200
215
  });
216
+
217
+ //TODO: move to separate function for connect
218
+ console.log('connect_allowed_callbacks_urls ->', connectAllowedCallbacksUrls);
219
+ console.log('connect_allowed_logout_urls ->', connectAllowedLogoutUrls);
220
+
221
+ await updateJsonFile(filePaths.connectJson, {
222
+ callbacks: connectAllowedCallbacksUrls,
223
+ allowed_logout_urls: connectAllowedLogoutUrls,
224
+ });
225
+
201
226
  console.log('Updated URLs for main UI...');
202
227
  } else {
203
228
  await fs.promises.unlink(filePaths.uiJson);
@@ -278,6 +303,9 @@ async function getAuth0AuthToken(auth0Domain, clientId, clientSecret) {
278
303
 
279
304
  async function configureUI(siteHost, coreURL, docupaceHost, site, env, useNewDomain, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, vaultSiteSecretsPath, imageTag, repoPath) {
280
305
  console.log(`Configuring UI for site: ${site} Host: ${siteHost} in env: ${env}`);
306
+ siteHost = siteHost.replace('https://', '');
307
+ coreURL = coreURL.replace('https://', '');
308
+
281
309
 
282
310
  try {
283
311
  const auth0Response = await axios.get(`https://${auth0Domain}/api/v2/clients`, {
@@ -405,6 +433,8 @@ externalConnectService:
405
433
  }
406
434
 
407
435
  async function configureGraphQLServer(siteHost, coreURL, docupaceHost, site, env, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, vaultSiteSecretsPath, imageTag, standardConfigRemoteBranch, repoPath, commonSecrets) {
436
+ siteHost = siteHost.replace('https://', '');
437
+ coreURL = coreURL.replace('https://', '');
408
438
  console.log(`Configuring GraphQL Server for site: ${site} Host: ${siteHost} in env: ${env}`);
409
439
 
410
440
  try {
@@ -508,7 +538,8 @@ ingress:
508
538
  }
509
539
  }
510
540
 
511
- export async function configureFromSite(fromSite, toSite, env,fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain) {
541
+
542
+ export async function configureFromSite(fromSite, toSite, fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain) {
512
543
  console.log(`Configuring Auth0 tenants and ArgoCD apps for site: ${toSite} in env: ${env} from site: ${fromSite}`);
513
544
  // Common Secrets
514
545
  const commonSecretsPath = getVaultSecretsConfigs(toSite).commonSecretsPath;
@@ -533,15 +564,27 @@ export async function configureFromSite(fromSite, toSite, env,fromEnv,toEnv, dep
533
564
  const graphqlSecretsPath = getVaultSecretsConfigs(toSite).graphqlServerSecretsPath;
534
565
  console.log(`graphqlSecretsPath => ${graphqlSecretsPath}`);
535
566
 
567
+ let repoPathFromEnv ="";
568
+ let repoPathToEnv = "";
536
569
  // Clone repositories
537
- const repoPath = await cloneEnvRepository(toEnv);
570
+ if ( fromEnv == toEnv ) {
571
+ repoPathFromEnv = await cloneEnvRepository(fromEnv);
572
+ repoPathToEnv = repoPathFromEnv;
573
+ }else {
574
+ repoPathFromEnv = await cloneEnvRepository(fromEnv);
575
+ repoPathToEnv = await cloneEnvRepository(toEnv);
576
+ }
577
+
578
+
579
+ //TODO: clone fromEnv and toEnv. replace above with this
580
+
538
581
  const auth0RepoPath = await cloneRepository('auth0-site-setup');
539
582
 
540
583
  // Read deploy configs
541
- const { deployConfig: deployUIConfig } = await readDeployConfig('ui', env, fromSite, 'values');
584
+ const { deployConfig: deployUIConfig } = await readDeployConfig('ui', fromEnv, fromSite, 'values');
542
585
  const uiImageTag = deployUIConfig.image.tag;
543
586
 
544
- const { deployConfig: deployGraphQLServerConfig} = await readDeployConfig('graphql-server', env, fromSite, 'values');
587
+ const { deployConfig: deployGraphQLServerConfig} = await readDeployConfig('graphql-server', fromEnv, fromSite, 'values');
545
588
  const graphqlImageTag = deployGraphQLServerConfig.image.tag;
546
589
  const graphqlStandardConfigRemoteBranch = deployGraphQLServerConfig.graphqlServer.standardConfigRemoteBranch;
547
590
 
@@ -552,6 +595,7 @@ export async function configureFromSite(fromSite, toSite, env,fromEnv,toEnv, dep
552
595
  loginHtml: './auth0-site-setup/template/pages/login.html',
553
596
  graphqlJson: './auth0-site-setup/template/clients/docupace-graphql.json',
554
597
  uiJson: './auth0-site-setup/template/clients/docupace-ui-main.json',
598
+ connectJson: './auth0-site-setup/template/clients/docupace-connect.json',
555
599
  databaseJson: './auth0-site-setup/template/database-connections/docupace/database.json',
556
600
  twilioJson: './auth0-site-setup/template/guardian/providers/sms-twilio.json',
557
601
  };
@@ -585,11 +629,11 @@ export async function configureFromSite(fromSite, toSite, env,fromEnv,toEnv, dep
585
629
  await importAuth0Templates('./auth0-site-setup/template', auth0Domain, auth0ClientId, auth0ClientSecret);
586
630
 
587
631
  if (deployUI === 'true') {
588
- await configureUI(SITE_HOST, CORE_URL, DOCUPACE_HOST, toSite, env, useNewDomain, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, uiSecretsPath, uiImageTag, repoPath);
632
+ await configureUI(SITE_HOST, CORE_URL, DOCUPACE_HOST, toSite, toEnv, useNewDomain, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, uiSecretsPath, uiImageTag, repoPathToEnv);
589
633
  }
590
634
 
591
- await configureGraphQLServer(SITE_HOST, CORE_URL, DOCUPACE_HOST, toSite, env, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, graphqlSecretsPath, graphqlImageTag, graphqlStandardConfigRemoteBranch, repoPath, commonSecrets);
592
- await pushDeployConfig(repoPath, `Config update for ${toSite} from ${fromSite} with UI: ${uiImageTag} and GraphQL: ${graphqlImageTag}`);
635
+ await configureGraphQLServer(SITE_HOST, CORE_URL, DOCUPACE_HOST, toSite, env, auth0Domain, auth0ClientId, auth0ClientSecret, auth0Token, graphqlSecretsPath, graphqlImageTag, graphqlStandardConfigRemoteBranch, repoPathToEnv, commonSecrets);
636
+ await pushDeployConfig(repoPathToEnv, `Config update for ${toSite} from ${fromSite} with UI: ${uiImageTag} and GraphQL: ${graphqlImageTag}`);
593
637
 
594
638
  await initializeAuth0Configuration({
595
639
  initConfiguration: "true",
@@ -604,4 +648,4 @@ export async function configureFromSite(fromSite, toSite, env,fromEnv,toEnv, dep
604
648
  auth0AuthToken: auth0Token,
605
649
  coreApiIdentifier: commonSecrets.CORE_API_IDENTIFIER
606
650
  })
607
- }
651
+ }
@@ -19,21 +19,22 @@ export async function addApacheSite() {
19
19
  log('Error: HAPROXY_PRIVATE_KEY not set.');
20
20
  process.exit(1);
21
21
  }
22
-
23
- //await fs.writeFile('private.key', haproxyPrivateKey);
24
- await $`echo "${haproxyPrivateKey}" > private.key`;
22
+
23
+ await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
25
24
  await fs.chmod('private.key', 0o600);
26
- console.log(await $`echo "key:";cat private.key|base64`);
27
-
28
25
 
29
- const server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
30
- console.log("Running command:");
31
- const sshCmd = (script) =>
26
+
27
+ console.log("Running command");
28
+ const sshCmd = (server,script) =>
32
29
  $`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
33
30
 
31
+ let server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
34
32
  // The script is run twice in the Bash version
35
- await sshCmd(`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
36
- //await sshCmd(`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
33
+ await sshCmd(server, `/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
34
+
35
+ server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
36
+
37
+ await sshCmd(server,`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
37
38
  }
38
39
 
39
40