@docupace/pipeline 1.0.24-alpha-4 → 1.0.26-alpha-1
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 +1 -1
- package/src/auth0/alias.js +36 -39
- package/src/auth0/cli.js +28 -14
- package/src/auth0/configure.js +230 -143
- package/src/auth0/vault.js +13 -13
- package/terraform/plan.sh +6 -4
package/package.json
CHANGED
package/src/auth0/alias.js
CHANGED
|
@@ -1,75 +1,72 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
createAlias
|
|
5
|
-
} from '../next/alias.js';
|
|
3
|
+
import { createAlias } from '../next/alias.js';
|
|
6
4
|
|
|
7
|
-
import {getAuth0AuthToken} from './configure.js';
|
|
5
|
+
import { getAuth0AuthToken } from './configure.js';
|
|
8
6
|
|
|
9
|
-
import {
|
|
10
|
-
getVaultSecrets,
|
|
11
|
-
} from './vault.js';
|
|
7
|
+
import { getVaultSecrets } from './vault.js';
|
|
12
8
|
|
|
13
|
-
import {
|
|
14
|
-
getVaultSecretsConfigs,
|
|
15
|
-
} from '../next/config.js';
|
|
9
|
+
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
16
10
|
|
|
17
|
-
import {
|
|
18
|
-
cloneEnvRepository,
|
|
19
|
-
readDeployConfig,
|
|
20
|
-
} from '../next/deploy.js';
|
|
11
|
+
import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
|
|
21
12
|
|
|
22
|
-
export async function getCCAlias
|
|
13
|
+
export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
|
|
23
14
|
console.log(`Forming alias name for application ${application}...`);
|
|
24
15
|
|
|
25
16
|
try {
|
|
26
|
-
const auth0Response = await axios.get(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
);
|
|
31
27
|
const appAuth0ClientId = appAuth0ClientIdData.client_id;
|
|
32
28
|
|
|
33
29
|
console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
|
|
34
30
|
return `${appAuth0ClientId}@clients`;
|
|
35
31
|
} catch (err) {
|
|
36
|
-
console.error(
|
|
32
|
+
console.error(
|
|
33
|
+
`Failed to form alias name for application: ${application}: ${err.message}`,
|
|
34
|
+
);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
export async function configureAlias(site, env, username, password, realm) {
|
|
41
|
-
|
|
42
39
|
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
40
|
// Site Common Secrets
|
|
49
|
-
const siteCommonSecretsPath =
|
|
50
|
-
|
|
41
|
+
const siteCommonSecretsPath =
|
|
42
|
+
getVaultSecretsConfigs(site).siteCommonSecretsPath;
|
|
43
|
+
console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
|
|
51
44
|
const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
|
|
52
45
|
|
|
53
|
-
const auth0Domain = `docupace-${env}-${site}.us.auth0.com
|
|
46
|
+
const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
|
|
54
47
|
const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
55
48
|
const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
56
|
-
const auth0Token = await getAuth0AuthToken(
|
|
49
|
+
const auth0Token = await getAuth0AuthToken(
|
|
50
|
+
auth0Domain,
|
|
51
|
+
auth0ClientId,
|
|
52
|
+
auth0ClientSecret,
|
|
53
|
+
);
|
|
57
54
|
|
|
58
55
|
await cloneEnvRepository(env);
|
|
59
56
|
|
|
60
|
-
const { deployConfig: deployGraphQLServerConfig} = await readDeployConfig(
|
|
57
|
+
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
58
|
+
'graphql-server',
|
|
59
|
+
env,
|
|
60
|
+
site,
|
|
61
|
+
'values',
|
|
62
|
+
);
|
|
61
63
|
const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
|
|
62
64
|
|
|
63
65
|
const clientCredentialsAlias = await getCCAlias({
|
|
64
66
|
application: 'docupace-graphql-client-credentials',
|
|
65
67
|
auth0Domain: auth0Domain,
|
|
66
|
-
auth0AuthToken: auth0Token
|
|
68
|
+
auth0AuthToken: auth0Token,
|
|
67
69
|
});
|
|
68
70
|
|
|
69
|
-
await createAlias(
|
|
70
|
-
coreUrl,
|
|
71
|
-
username,
|
|
72
|
-
password,
|
|
73
|
-
realm,
|
|
74
|
-
clientCredentialsAlias);
|
|
71
|
+
await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
|
|
75
72
|
}
|
package/src/auth0/cli.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from './configure.js';
|
|
7
|
-
import {
|
|
8
|
-
getVaultSecrets
|
|
9
|
-
} from './vault.js'
|
|
4
|
+
import { configureFromSite } from './configure.js';
|
|
5
|
+
import { getVaultSecrets } from './vault.js';
|
|
10
6
|
|
|
11
7
|
import dotenv from 'dotenv';
|
|
12
|
-
import {
|
|
13
|
-
configureAlias
|
|
14
|
-
} from "./alias.js";
|
|
8
|
+
import { configureAlias } from './alias.js';
|
|
15
9
|
|
|
16
10
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
17
11
|
|
|
18
12
|
const program = new Command();
|
|
19
13
|
|
|
20
14
|
program
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
);
|
|
26
40
|
|
|
27
41
|
program
|
|
28
42
|
.command('getVaultSecrets <vaultPath>')
|
package/src/auth0/configure.js
CHANGED
|
@@ -2,26 +2,15 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
|
-
import fl from 'fs/promises';
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
cloneEnvRepository,
|
|
9
|
-
cloneRepository,
|
|
10
8
|
readDeployConfig,
|
|
11
|
-
pushDeployConfig
|
|
9
|
+
pushDeployConfig,
|
|
12
10
|
} from '../next/deploy.js';
|
|
13
11
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
updateVaultSecrets
|
|
17
|
-
} from './vault.js';
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
getVaultSecretsConfigs,
|
|
21
|
-
environmentConfig
|
|
22
|
-
} from '../next/config.js';
|
|
23
|
-
import { connect } from 'http2';
|
|
24
|
-
import { promise } from 'zod';
|
|
12
|
+
import { getVaultSecrets, updateVaultSecrets } from './vault.js';
|
|
13
|
+
import { getVaultSecretsConfigs, environmentConfig } from '../next/config.js';
|
|
25
14
|
|
|
26
15
|
async function ensureDirectoryExists(dirPath) {
|
|
27
16
|
try {
|
|
@@ -32,68 +21,77 @@ async function ensureDirectoryExists(dirPath) {
|
|
|
32
21
|
}
|
|
33
22
|
}
|
|
34
23
|
|
|
35
|
-
async function copyDirectory(source, destination) {
|
|
36
|
-
try {
|
|
37
|
-
await fl.mkdir(destination, { recursive: true });
|
|
38
|
-
const items = await fl.readdir(source, { withFileTypes: true });
|
|
39
|
-
|
|
40
|
-
for (const item of items) {
|
|
41
|
-
const sourcePath = path.join(source, item.name);
|
|
42
|
-
const destinationPath = path.join(destination, item.name);
|
|
43
|
-
|
|
44
|
-
if (item.isDirectory()) {
|
|
45
|
-
await copyDirectory(sourcePath, destinationPath);
|
|
46
|
-
} else {
|
|
47
|
-
await fl.copyFile(sourcePath, destinationPath);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error(`Error copying directory: ${err.message}`);
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
24
|
export async function getAuth0AuthToken(auth0Domain, clientId, clientSecret) {
|
|
57
25
|
try {
|
|
58
|
-
const response = await axios.post(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'Content-Type': 'application/json',
|
|
26
|
+
const response = await axios.post(
|
|
27
|
+
`https://${auth0Domain}/oauth/token`,
|
|
28
|
+
{
|
|
29
|
+
client_id: clientId,
|
|
30
|
+
client_secret: clientSecret,
|
|
31
|
+
audience: `https://${auth0Domain}/api/v2/`,
|
|
32
|
+
grant_type: 'client_credentials',
|
|
66
33
|
},
|
|
67
|
-
|
|
34
|
+
{
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
68
40
|
|
|
69
41
|
const authToken = response.data.access_token;
|
|
70
42
|
// console.log("Auth0 Auth Token:", authToken);
|
|
71
43
|
return authToken;
|
|
72
44
|
} catch (error) {
|
|
73
|
-
console.error(
|
|
45
|
+
console.error(
|
|
46
|
+
'Error fetching Auth0 token:',
|
|
47
|
+
error.response ? error.response.data : error.message,
|
|
48
|
+
);
|
|
74
49
|
}
|
|
75
50
|
}
|
|
76
51
|
|
|
77
|
-
async function configureUI(
|
|
78
|
-
|
|
52
|
+
async function configureUI(
|
|
53
|
+
siteHost,
|
|
54
|
+
coreURL,
|
|
55
|
+
docupaceHost,
|
|
56
|
+
site,
|
|
57
|
+
env,
|
|
58
|
+
useNewDomain,
|
|
59
|
+
auth0Domain,
|
|
60
|
+
auth0ClientId,
|
|
61
|
+
auth0ClientSecret,
|
|
62
|
+
auth0Token,
|
|
63
|
+
vaultSiteSecretsPath,
|
|
64
|
+
imageTag,
|
|
65
|
+
repoPath,
|
|
66
|
+
) {
|
|
67
|
+
console.log(
|
|
68
|
+
`Configuring UI for site: ${site} Host: ${siteHost} in env: ${env}`,
|
|
69
|
+
);
|
|
79
70
|
siteHost = siteHost.replace('https://', '');
|
|
80
71
|
coreURL = coreURL.replace('https://', '');
|
|
81
72
|
|
|
82
|
-
|
|
83
73
|
try {
|
|
84
|
-
const auth0Response = await axios.get(
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
const auth0Response = await axios.get(
|
|
75
|
+
`https://${auth0Domain}/api/v2/clients`,
|
|
76
|
+
{
|
|
77
|
+
headers: { authorization: `Bearer ${auth0Token}` },
|
|
78
|
+
},
|
|
79
|
+
);
|
|
87
80
|
|
|
88
|
-
const uiClient = auth0Response.data.find(
|
|
81
|
+
const uiClient = auth0Response.data.find(
|
|
82
|
+
(client) => client.name === 'docupace-ui-main',
|
|
83
|
+
);
|
|
89
84
|
const uiAuth0ClientId = uiClient.client_id;
|
|
90
85
|
const uiAuth0ClientSecret = uiClient.client_secret;
|
|
91
86
|
|
|
92
87
|
// Generate Auth0 Secret
|
|
93
|
-
const uiAuth0Secret = crypto
|
|
88
|
+
const uiAuth0Secret = crypto
|
|
89
|
+
.randomBytes(48)
|
|
90
|
+
.toString('base64')
|
|
91
|
+
.replace(/[^a-zA-Z0-9]/g, '');
|
|
94
92
|
|
|
95
93
|
// Prepare data payload
|
|
96
|
-
console.log(
|
|
94
|
+
console.log('Preparing Vault UI data payload...');
|
|
97
95
|
const uiSecretData = JSON.stringify({
|
|
98
96
|
data: {
|
|
99
97
|
AUTH0_CLIENT_ID: uiAuth0ClientId,
|
|
@@ -181,51 +179,85 @@ externalConnectService:
|
|
|
181
179
|
`.trim();
|
|
182
180
|
|
|
183
181
|
// Write configuration files
|
|
184
|
-
console.log(
|
|
182
|
+
console.log('Writing configuration files...');
|
|
185
183
|
await ensureDirectoryExists(path.resolve(`${repoPath}/dp/${site}`));
|
|
186
184
|
|
|
187
|
-
await fs.writeFile(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
185
|
+
await fs.writeFile(
|
|
186
|
+
`${repoPath}/dp/${site}/ui.app.yaml`,
|
|
187
|
+
uiAppYaml,
|
|
188
|
+
(err) => {
|
|
189
|
+
if (err) {
|
|
190
|
+
console.error('Failed to write the file:', err);
|
|
191
|
+
} else {
|
|
192
|
+
console.log('File written successfully.');
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
await fs.writeFile(
|
|
198
|
+
`${repoPath}/dp/${site}/ui.values.yaml`,
|
|
199
|
+
uiValuesYaml,
|
|
200
|
+
(err) => {
|
|
201
|
+
if (err) {
|
|
202
|
+
console.error('Failed to write the file:', err);
|
|
203
|
+
} else {
|
|
204
|
+
console.log('File written successfully.');
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
console.log('Done!');
|
|
203
209
|
} catch (error) {
|
|
204
|
-
console.error(
|
|
210
|
+
console.error('Error configuring UI:', error);
|
|
205
211
|
}
|
|
206
212
|
}
|
|
207
213
|
|
|
208
|
-
async function configureGraphQLServer(
|
|
214
|
+
async function configureGraphQLServer(
|
|
215
|
+
siteHost,
|
|
216
|
+
coreURL,
|
|
217
|
+
docupaceHost,
|
|
218
|
+
site,
|
|
219
|
+
env,
|
|
220
|
+
auth0Domain,
|
|
221
|
+
auth0ClientId,
|
|
222
|
+
auth0ClientSecret,
|
|
223
|
+
auth0Token,
|
|
224
|
+
vaultSiteSecretsPath,
|
|
225
|
+
imageTag,
|
|
226
|
+
standardConfigRemoteBranch,
|
|
227
|
+
repoPath,
|
|
228
|
+
commonSecrets,
|
|
229
|
+
) {
|
|
209
230
|
siteHost = siteHost.replace('https://', '');
|
|
210
231
|
coreURL = coreURL.replace('https://', '');
|
|
211
|
-
console.log(
|
|
232
|
+
console.log(
|
|
233
|
+
`Configuring GraphQL Server for site: ${site} Host: ${siteHost} in env: ${env}`,
|
|
234
|
+
);
|
|
212
235
|
|
|
213
236
|
try {
|
|
214
|
-
const auth0Response = await axios.get(
|
|
215
|
-
|
|
216
|
-
|
|
237
|
+
const auth0Response = await axios.get(
|
|
238
|
+
`https://${auth0Domain}/api/v2/clients`,
|
|
239
|
+
{
|
|
240
|
+
headers: { authorization: `Bearer ${auth0Token}` },
|
|
241
|
+
},
|
|
242
|
+
);
|
|
217
243
|
|
|
218
|
-
const graphQLServerClient = auth0Response.data.find(
|
|
219
|
-
|
|
244
|
+
const graphQLServerClient = auth0Response.data.find(
|
|
245
|
+
(client) => client.name === 'docupace-graphql',
|
|
246
|
+
);
|
|
247
|
+
const graphQLServerClientCredentials = auth0Response.data.find(
|
|
248
|
+
(client) => client.name === 'docupace-graphql-client-credentials',
|
|
249
|
+
);
|
|
220
250
|
|
|
221
251
|
const graphQLServerAuth0ClientId = graphQLServerClient.client_id;
|
|
222
252
|
const graphQLServerAuth0ClientSecret = graphQLServerClient.client_secret;
|
|
223
253
|
|
|
224
|
-
const graphQLServerCCAuth0ClientId =
|
|
225
|
-
|
|
254
|
+
const graphQLServerCCAuth0ClientId =
|
|
255
|
+
graphQLServerClientCredentials.client_id;
|
|
256
|
+
const graphQLServerCCAuth0ClientSecret =
|
|
257
|
+
graphQLServerClientCredentials.client_secret;
|
|
226
258
|
|
|
227
259
|
// Prepare data payload
|
|
228
|
-
console.log(
|
|
260
|
+
console.log('Preparing Vault GraphQL Server data payload...');
|
|
229
261
|
const graphQLServerSecretData = JSON.stringify({
|
|
230
262
|
data: {
|
|
231
263
|
AUTH0_CLIENT_ID: graphQLServerAuth0ClientId,
|
|
@@ -288,64 +320,88 @@ ingress:
|
|
|
288
320
|
`.trim();
|
|
289
321
|
|
|
290
322
|
// Write configuration files
|
|
291
|
-
console.log(
|
|
323
|
+
console.log('Writing ArgoCD GraphQL Server configuration files...');
|
|
292
324
|
await ensureDirectoryExists(path.resolve(`${repoPath}/dp/${site}`));
|
|
293
325
|
|
|
294
|
-
await fs.writeFile(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
326
|
+
await fs.writeFile(
|
|
327
|
+
`${repoPath}/dp/${site}/graphql-server.app.yaml`,
|
|
328
|
+
graphQLServerAppYaml,
|
|
329
|
+
(err) => {
|
|
330
|
+
if (err) {
|
|
331
|
+
console.error('Failed to write the file:', err);
|
|
332
|
+
} else {
|
|
333
|
+
console.log('File written successfully.');
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
await fs.writeFile(
|
|
339
|
+
`${repoPath}/dp/${site}/graphql-server.values.yaml`,
|
|
340
|
+
graphQLServerValuesYaml,
|
|
341
|
+
(err) => {
|
|
342
|
+
if (err) {
|
|
343
|
+
console.error('Failed to write the file:', err);
|
|
344
|
+
} else {
|
|
345
|
+
console.log('File written successfully.');
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
);
|
|
349
|
+
console.log('Done!');
|
|
310
350
|
} catch (error) {
|
|
311
|
-
console.error(
|
|
351
|
+
console.error('Error configuring GraphQL Server:', error);
|
|
312
352
|
}
|
|
313
353
|
}
|
|
314
354
|
|
|
315
|
-
export async function configureFromSite(
|
|
316
|
-
|
|
355
|
+
export async function configureFromSite(
|
|
356
|
+
fromSite,
|
|
357
|
+
toSite,
|
|
358
|
+
fromEnv,
|
|
359
|
+
toEnv,
|
|
360
|
+
deployUI,
|
|
361
|
+
deployGraphQLServer,
|
|
362
|
+
useNewDomain,
|
|
363
|
+
) {
|
|
364
|
+
console.log(
|
|
365
|
+
`Configuring Auth0 tenants and ArgoCD apps for site: ${toSite} in env: ${toEnv} from site: ${fromSite}`,
|
|
366
|
+
);
|
|
317
367
|
// Common Secrets
|
|
318
368
|
const commonSecretsPath = getVaultSecretsConfigs(toSite).commonSecretsPath;
|
|
319
|
-
console.log(`commonSecretsPath => ${commonSecretsPath}`)
|
|
369
|
+
console.log(`commonSecretsPath => ${commonSecretsPath}`);
|
|
320
370
|
const commonSecrets = await getVaultSecrets(commonSecretsPath);
|
|
321
371
|
|
|
322
372
|
// Site Common Secrets
|
|
323
|
-
const siteCommonSecretsPath =
|
|
324
|
-
|
|
373
|
+
const siteCommonSecretsPath =
|
|
374
|
+
getVaultSecretsConfigs(toSite).siteCommonSecretsPath;
|
|
375
|
+
console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
|
|
325
376
|
const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
|
|
326
377
|
|
|
327
|
-
const auth0Domain = `docupace-${toEnv}-${toSite}.us.auth0.com
|
|
378
|
+
const auth0Domain = `docupace-${toEnv}-${toSite}.us.auth0.com`;
|
|
328
379
|
const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
329
380
|
const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
330
|
-
const auth0Token = await getAuth0AuthToken(
|
|
381
|
+
const auth0Token = await getAuth0AuthToken(
|
|
382
|
+
auth0Domain,
|
|
383
|
+
auth0ClientId,
|
|
384
|
+
auth0ClientSecret,
|
|
385
|
+
);
|
|
331
386
|
|
|
332
387
|
// UI app
|
|
333
388
|
const uiSecretsPath = getVaultSecretsConfigs(toSite).uiSecretsPath;
|
|
334
|
-
console.log(`uiSecretsPath => ${uiSecretsPath}`)
|
|
389
|
+
console.log(`uiSecretsPath => ${uiSecretsPath}`);
|
|
335
390
|
|
|
336
391
|
// GraphQL-Server app
|
|
337
|
-
const graphqlSecretsPath =
|
|
392
|
+
const graphqlSecretsPath =
|
|
393
|
+
getVaultSecretsConfigs(toSite).graphqlServerSecretsPath;
|
|
338
394
|
console.log(`graphqlSecretsPath => ${graphqlSecretsPath}`);
|
|
339
395
|
|
|
340
|
-
let repoPathFromEnv =
|
|
341
|
-
let repoPathToEnv =
|
|
396
|
+
let repoPathFromEnv = '';
|
|
397
|
+
let repoPathToEnv = '';
|
|
342
398
|
// Clone repositories
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
399
|
+
if (fromEnv === toEnv) {
|
|
400
|
+
repoPathFromEnv = await cloneEnvRepository(fromEnv);
|
|
401
|
+
repoPathToEnv = repoPathFromEnv;
|
|
346
402
|
} else {
|
|
347
|
-
|
|
348
|
-
|
|
403
|
+
repoPathFromEnv = await cloneEnvRepository(fromEnv);
|
|
404
|
+
repoPathToEnv = await cloneEnvRepository(toEnv);
|
|
349
405
|
}
|
|
350
406
|
|
|
351
407
|
//TODO: clone fromEnv and toEnv. replace above with this
|
|
@@ -353,39 +409,39 @@ export async function configureFromSite(fromSite, toSite, fromEnv,toEnv, deployU
|
|
|
353
409
|
// const auth0RepoPath = await cloneRepository('auth0-site-setup');
|
|
354
410
|
|
|
355
411
|
// Read deploy configs
|
|
356
|
-
const { deployConfig: deployUIConfig } = await readDeployConfig(
|
|
412
|
+
const { deployConfig: deployUIConfig } = await readDeployConfig(
|
|
413
|
+
'ui',
|
|
414
|
+
fromEnv,
|
|
415
|
+
fromSite,
|
|
416
|
+
'values',
|
|
417
|
+
);
|
|
357
418
|
const uiImageTag = deployUIConfig.image.tag;
|
|
358
419
|
|
|
359
|
-
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
420
|
+
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
421
|
+
'graphql-server',
|
|
422
|
+
fromEnv,
|
|
423
|
+
fromSite,
|
|
424
|
+
'values',
|
|
425
|
+
);
|
|
360
426
|
const graphqlImageTag = deployGraphQLServerConfig.image.tag;
|
|
361
|
-
const graphqlStandardConfigRemoteBranch =
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
databaseJson: './auth0-site-setup/template/database-connections/docupace/database.json',
|
|
371
|
-
twilioJson: './auth0-site-setup/template/guardian/providers/sms-twilio.json',
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
console.log(`Copying Latest UI Image Tag: ${deployUIConfig.image.tag} from site: ${fromSite} to site: ${toSite}`);
|
|
375
|
-
console.log(`Copying Latest GraphQL Server Image Tag: ${deployGraphQLServerConfig.image.tag} from site: ${fromSite} to site: ${toSite}`);
|
|
427
|
+
const graphqlStandardConfigRemoteBranch =
|
|
428
|
+
deployGraphQLServerConfig.graphqlServer.standardConfigRemoteBranch;
|
|
429
|
+
|
|
430
|
+
console.log(
|
|
431
|
+
`Copying Latest UI Image Tag: ${deployUIConfig.image.tag} from site: ${fromSite} to site: ${toSite}`,
|
|
432
|
+
);
|
|
433
|
+
console.log(
|
|
434
|
+
`Copying Latest GraphQL Server Image Tag: ${deployGraphQLServerConfig.image.tag} from site: ${fromSite} to site: ${toSite}`,
|
|
435
|
+
);
|
|
376
436
|
|
|
377
437
|
const envConfig = environmentConfig[toEnv];
|
|
378
438
|
|
|
379
|
-
let CORE_URL,
|
|
380
|
-
SITE_HOST,
|
|
381
|
-
CORE_API_CONTEXT,
|
|
382
|
-
CONNECT_URL,
|
|
383
|
-
DOCUPACE_HOST;
|
|
439
|
+
let CORE_URL, SITE_HOST, CORE_API_CONTEXT, CONNECT_URL, DOCUPACE_HOST;
|
|
384
440
|
if (useNewDomain) {
|
|
385
441
|
const newUrl = envConfig.newUrl(toSite);
|
|
386
442
|
CORE_URL = `${newUrl}/core`;
|
|
387
443
|
SITE_HOST = newUrl;
|
|
388
|
-
CORE_API_CONTEXT =
|
|
444
|
+
CORE_API_CONTEXT = 'core';
|
|
389
445
|
CONNECT_URL = `${newUrl}/connect`;
|
|
390
446
|
DOCUPACE_HOST = envConfig.docupaceHost();
|
|
391
447
|
} else {
|
|
@@ -397,10 +453,41 @@ export async function configureFromSite(fromSite, toSite, fromEnv,toEnv, deployU
|
|
|
397
453
|
}
|
|
398
454
|
|
|
399
455
|
if (deployUI === 'true') {
|
|
400
|
-
await configureUI(
|
|
456
|
+
await configureUI(
|
|
457
|
+
SITE_HOST,
|
|
458
|
+
CORE_URL,
|
|
459
|
+
DOCUPACE_HOST,
|
|
460
|
+
toSite,
|
|
461
|
+
toEnv,
|
|
462
|
+
useNewDomain,
|
|
463
|
+
auth0Domain,
|
|
464
|
+
auth0ClientId,
|
|
465
|
+
auth0ClientSecret,
|
|
466
|
+
auth0Token,
|
|
467
|
+
uiSecretsPath,
|
|
468
|
+
uiImageTag,
|
|
469
|
+
repoPathToEnv,
|
|
470
|
+
);
|
|
401
471
|
}
|
|
402
472
|
|
|
403
|
-
await configureGraphQLServer(
|
|
404
|
-
|
|
405
|
-
|
|
473
|
+
await configureGraphQLServer(
|
|
474
|
+
SITE_HOST,
|
|
475
|
+
CORE_URL,
|
|
476
|
+
DOCUPACE_HOST,
|
|
477
|
+
toSite,
|
|
478
|
+
toEnv,
|
|
479
|
+
auth0Domain,
|
|
480
|
+
auth0ClientId,
|
|
481
|
+
auth0ClientSecret,
|
|
482
|
+
auth0Token,
|
|
483
|
+
graphqlSecretsPath,
|
|
484
|
+
graphqlImageTag,
|
|
485
|
+
graphqlStandardConfigRemoteBranch,
|
|
486
|
+
repoPathToEnv,
|
|
487
|
+
commonSecrets,
|
|
488
|
+
);
|
|
489
|
+
await pushDeployConfig(
|
|
490
|
+
repoPathToEnv,
|
|
491
|
+
`Config update for ${toSite} from ${fromSite} with UI: ${uiImageTag} and GraphQL: ${graphqlImageTag}`,
|
|
492
|
+
);
|
|
406
493
|
}
|
package/src/auth0/vault.js
CHANGED
|
@@ -7,16 +7,16 @@ import axios from 'axios';
|
|
|
7
7
|
*/
|
|
8
8
|
export async function getVaultSecrets(vaultPath) {
|
|
9
9
|
if (!vaultPath) {
|
|
10
|
-
console.error(
|
|
11
|
-
throw new Error(
|
|
10
|
+
console.error('Error: VAULT_PATH is required.');
|
|
11
|
+
throw new Error('VAULT_PATH is required.');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const vaultToken = process.env.VAULT_TOKEN;
|
|
15
15
|
const vaultAddr = process.env.VAULT_ADDR;
|
|
16
16
|
|
|
17
17
|
if (!vaultToken || !vaultAddr) {
|
|
18
|
-
console.error(
|
|
19
|
-
throw new Error(
|
|
18
|
+
console.error('Error: VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
19
|
+
throw new Error('VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
try {
|
|
@@ -38,13 +38,13 @@ export async function getVaultSecrets(vaultPath) {
|
|
|
38
38
|
// console.log(`Secrets fetched successfully from Vault at ${JSON.stringify(data.data.data)})`);
|
|
39
39
|
return data.data.data;
|
|
40
40
|
} else {
|
|
41
|
-
console.error(
|
|
42
|
-
throw new Error(
|
|
41
|
+
console.error('Error: Invalid JSON received from Vault.');
|
|
42
|
+
throw new Error('Invalid JSON received from Vault.');
|
|
43
43
|
}
|
|
44
44
|
} catch (error) {
|
|
45
45
|
if (error.response) {
|
|
46
46
|
console.error(
|
|
47
|
-
`Error: Failed to connect to Vault server at ${vaultAddr}. Response: ${error.response.status} ${error.response.statusText}
|
|
47
|
+
`Error: Failed to connect to Vault server at ${vaultAddr}. Response: ${error.response.status} ${error.response.statusText}`,
|
|
48
48
|
);
|
|
49
49
|
} else {
|
|
50
50
|
console.error(`Error: ${error.message}`);
|
|
@@ -61,16 +61,16 @@ export async function getVaultSecrets(vaultPath) {
|
|
|
61
61
|
*/
|
|
62
62
|
export async function updateVaultSecrets(vaultPath, secretData) {
|
|
63
63
|
if (!vaultPath || !secretData) {
|
|
64
|
-
console.error(
|
|
65
|
-
throw new Error(
|
|
64
|
+
console.error('Usage: updateVaultSecret(vaultPath, secretData)');
|
|
65
|
+
throw new Error('Both vaultPath and secretData are required.');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const vaultToken = process.env.VAULT_TOKEN;
|
|
69
69
|
const vaultAddr = process.env.VAULT_ADDR;
|
|
70
70
|
|
|
71
71
|
if (!vaultToken || !vaultAddr) {
|
|
72
|
-
console.error(
|
|
73
|
-
throw new Error(
|
|
72
|
+
console.error('Error: VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
73
|
+
throw new Error('VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
try {
|
|
@@ -88,7 +88,7 @@ export async function updateVaultSecrets(vaultPath, secretData) {
|
|
|
88
88
|
'X-Vault-Token': vaultToken,
|
|
89
89
|
'Content-Type': 'application/json',
|
|
90
90
|
},
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
// Return the response from Vault
|
|
@@ -97,7 +97,7 @@ export async function updateVaultSecrets(vaultPath, secretData) {
|
|
|
97
97
|
} catch (error) {
|
|
98
98
|
if (error.response) {
|
|
99
99
|
console.error(
|
|
100
|
-
`Error: Failed to update secret at ${vaultPath}. Response: ${error.response.status} ${error.response.statusText}
|
|
100
|
+
`Error: Failed to update secret at ${vaultPath}. Response: ${error.response.status} ${error.response.statusText}`,
|
|
101
101
|
);
|
|
102
102
|
} else {
|
|
103
103
|
console.error(`Error: ${error.message}`);
|
package/terraform/plan.sh
CHANGED
|
@@ -48,11 +48,13 @@ elif [[ "$PROJECT" == "idp" ]];then
|
|
|
48
48
|
terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" \
|
|
49
49
|
-var="site=${SITE_NAME}" \
|
|
50
50
|
-var="env=${CURRENT_ENVIRONMENT}" \
|
|
51
|
+
-var="docupace_domain=${DOCUPACE_DOMAIN}" \
|
|
52
|
+
-var="old_page_design=${USE_OLD_PAGE_DESIGN}" \
|
|
53
|
+
-var="use_new_domain=${USE_NEW_DOMAIN}" \
|
|
54
|
+
-var="configure_autologin=${CONFIGURE_AUTOLOGIN}" \
|
|
55
|
+
-var="configure_ui_main=${CONFIGURE_UI_MAIN}" \
|
|
56
|
+
-var="enable_mfa=${ENABLE_MFA}" \
|
|
51
57
|
-out .tfplan
|
|
52
58
|
else
|
|
53
59
|
terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" -out .tfplan
|
|
54
60
|
fi
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|