@docupace/pipeline 1.0.26-alpha-4 → 1.0.27

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.
@@ -1,72 +1,75 @@
1
- import axios from 'axios';
2
-
3
- import { createAlias } from '../next/alias.js';
4
-
5
- import { getAuth0AuthToken } from './configure.js';
6
-
7
- import { getVaultSecrets } from './vault.js';
8
-
9
- import { getVaultSecretsConfigs } from '../next/config.js';
10
-
11
- import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
12
-
13
- export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
14
- console.log(`Forming alias name for application ${application}...`);
15
-
16
- try {
17
- const auth0Response = await axios.get(
18
- `https://${auth0Domain}/api/v2/clients`,
19
- {
20
- headers: { authorization: `Bearer ${auth0AuthToken}` },
21
- },
22
- );
23
-
24
- const appAuth0ClientIdData = auth0Response.data.find(
25
- (client) => client.name === `${application}`,
26
- );
27
- const appAuth0ClientId = appAuth0ClientIdData.client_id;
28
-
29
- console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
30
- return `${appAuth0ClientId}@clients`;
31
- } catch (err) {
32
- console.error(
33
- `Failed to form alias name for application: ${application}: ${err.message}`,
34
- );
35
- }
36
- }
37
-
38
- export async function configureAlias(site, env, username, password, realm) {
39
- console.log(`Creating alias for site: ${site} in env: ${env}`);
40
- // Site Common Secrets
41
- const siteCommonSecretsPath =
42
- getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
44
- const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
45
-
46
- const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
47
- const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
48
- const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
49
- const auth0Token = await getAuth0AuthToken(
50
- auth0Domain,
51
- auth0ClientId,
52
- auth0ClientSecret,
53
- );
54
-
55
- await cloneEnvRepository(env);
56
-
57
- const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
- 'graphql-server',
59
- env,
60
- site,
61
- 'values',
62
- );
63
- const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
64
-
65
- const clientCredentialsAlias = await getCCAlias({
66
- application: 'docupace-graphql-client-credentials',
67
- auth0Domain: auth0Domain,
68
- auth0AuthToken: auth0Token,
69
- });
70
-
71
- await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
72
- }
1
+ import axios from 'axios';
2
+
3
+ import {
4
+ createAlias
5
+ } from '../next/alias.js';
6
+
7
+ import {getAuth0AuthToken} from './configure.js';
8
+
9
+ import {
10
+ getVaultSecrets,
11
+ } from './vault.js';
12
+
13
+ import {
14
+ getVaultSecretsConfigs,
15
+ } from '../next/config.js';
16
+
17
+ import {
18
+ cloneEnvRepository,
19
+ readDeployConfig,
20
+ } from '../next/deploy.js';
21
+
22
+ export async function getCCAlias ({application, auth0Domain, auth0AuthToken}){
23
+ console.log(`Forming alias name for application ${application}...`);
24
+
25
+ try {
26
+ const auth0Response = await axios.get(`https://${auth0Domain}/api/v2/clients`, {
27
+ headers: {authorization: `Bearer ${auth0AuthToken}`},
28
+ });
29
+
30
+ const appAuth0ClientIdData = auth0Response.data.find(client => client.name === `${application}`);
31
+ const appAuth0ClientId = appAuth0ClientIdData.client_id;
32
+
33
+ console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
34
+ return `${appAuth0ClientId}@clients`;
35
+ } catch (err) {
36
+ console.error(`Failed to form alias name for application: ${application}: ${err.message}`);
37
+ }
38
+ }
39
+
40
+ export async function configureAlias(site, env, username, password, realm) {
41
+
42
+ console.log(`Creating alias for site: ${site} in env: ${env}`);
43
+
44
+ const commonSecretsPath = getVaultSecretsConfigs(site).commonSecretsPath;
45
+ console.log(`commonSecretsPath => ${commonSecretsPath}`)
46
+ const commonSecrets = await getVaultSecrets(commonSecretsPath);
47
+
48
+ // Site Common Secrets
49
+ const siteCommonSecretsPath = getVaultSecretsConfigs(site).siteCommonSecretsPath;
50
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`)
51
+ const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
52
+
53
+ const auth0Domain = `docupace-${env}-${site}.us.auth0.com`
54
+ const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
55
+ const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
56
+ const auth0Token = await getAuth0AuthToken(auth0Domain, auth0ClientId, auth0ClientSecret);
57
+
58
+ await cloneEnvRepository(env);
59
+
60
+ const { deployConfig: deployGraphQLServerConfig} = await readDeployConfig('graphql-server', env, site, 'values');
61
+ const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
62
+
63
+ const clientCredentialsAlias = await getCCAlias({
64
+ application: 'docupace-graphql-client-credentials',
65
+ auth0Domain: auth0Domain,
66
+ auth0AuthToken: auth0Token
67
+ });
68
+
69
+ await createAlias(
70
+ coreUrl,
71
+ username,
72
+ password,
73
+ realm,
74
+ clientCredentialsAlias);
75
+ }
package/src/auth0/cli.js CHANGED
@@ -1,56 +1,41 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import { configureFromSite } from './configure.js';
5
- import { getVaultSecrets } from './vault.js';
6
-
7
- import dotenv from 'dotenv';
8
- import { configureAlias } from './alias.js';
9
-
10
- dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
11
-
12
- const program = new Command();
13
-
14
- program
15
- .command(
16
- 'configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain>',
17
- )
18
- .description('Configure the Auth0 tenants in env for the given site')
19
- .action(
20
- async (
21
- fromSite,
22
- toSite,
23
- fromEnv,
24
- toEnv,
25
- deployUI,
26
- deployGraphQLServer,
27
- useNewDomain,
28
- ) => {
29
- await configureFromSite(
30
- fromSite,
31
- toSite,
32
- fromEnv,
33
- toEnv,
34
- deployUI,
35
- deployGraphQLServer,
36
- useNewDomain,
37
- );
38
- },
39
- );
40
-
41
- program
42
- .command('getVaultSecrets <vaultPath>')
43
- .description('Get Secrets for Vault PATH')
44
- .action(async (vaultPath) => {
45
- const data = await getVaultSecrets(vaultPath);
46
- console.log(JSON.stringify(data, 'null', 2));
47
- });
48
-
49
- program
50
- .command('configureAlias <site> <env> <username> <password> <realm>')
51
- .description('Configure Core Alias for the given site')
52
- .action(async (site, env, username, password, realm) => {
53
- await configureAlias(site, env, username, password, realm);
54
- });
55
-
56
- program.parse(process.argv);
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import {
5
+ configureFromSite
6
+ } from './configure.js';
7
+ import {
8
+ getVaultSecrets
9
+ } from './vault.js'
10
+
11
+ import dotenv from 'dotenv';
12
+ import {
13
+ configureAlias
14
+ } from "./alias.js";
15
+
16
+ dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
17
+
18
+ const program = new Command();
19
+
20
+ program
21
+ .command('configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <configureMFA>')
22
+ .description('Configure the Auth0 tenants in env for the given site')
23
+ .action(async (fromSite, toSite, fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain, configureMFA) => {
24
+ await configureFromSite(fromSite, toSite, fromEnv, toEnv, deployUI, deployGraphQLServer, useNewDomain, configureMFA);
25
+ });
26
+
27
+ program
28
+ .command('getVaultSecrets <vaultPath>')
29
+ .description('Get Secrets for Vault PATH')
30
+ .action(async (vaultPath) => {
31
+ await getVaultSecrets(vaultPath);
32
+ });
33
+
34
+ program
35
+ .command('configureAlias <site> <env> <username> <password> <realm>')
36
+ .description('Configure Core Alias for the given site')
37
+ .action(async (site, env, username, password, realm) => {
38
+ await configureAlias(site, env, username, password, realm);
39
+ });
40
+
41
+ program.parse(process.argv);