Skip to content

Commit 511116a

Browse files
committed
removed ENV variables/secrets - DB configuration & profiles instead
1 parent d9fab35 commit 511116a

File tree

6 files changed

+51
-79
lines changed

6 files changed

+51
-79
lines changed

config.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ try {
2222
}
2323

2424
const activeProfile = process.env.ACTIVE_PROFILE || 'staging';
25-
console.log('Active profile:', activeProfile)
26-
console.log('__filename:',__filename);
27-
console.log('__dirname:',__dirname);
28-
console.log('process.cwd():',process.cwd());
25+
console.log('Active profile:', activeProfile);
2926
profiles.init({
30-
baseFolder: path.join(process.cwd(),'api/profiles'),
31-
dbUrl: profiles.getEnvironmentEntry(activeProfile, 'MONGO_URL'),
32-
encryptionDetails: profiles.getEnvironmentEntry(activeProfile, 'PROFILE_SECRET')
33-
}
34-
)
27+
baseFolder: path.join(process.cwd(), 'api/profiles'),
28+
dbUrl: profiles.getEnvironmentEntry(activeProfile, 'MONGO_URL'),
29+
encryptionDetails: profiles.getEnvironmentEntry(activeProfile, 'PROFILE_SECRET')
30+
}
31+
);
3532

3633

3734

@@ -66,12 +63,13 @@ const determineEnviroment = () => {
6663
};
6764

6865
const environment = determineEnviroment();
69-
console.log('###########ENV:',environment);
70-
console.log('ENV:',environment);
66+
console.log('###########ENV:', environment);
67+
console.log('ENV:', environment);
68+
console.log('process.env:', process.env);
7169
// Get an an environment variable
7270
const getConfigKey = (key) => {
7371
// Return environment specific variable if any
74-
return profiles.getEnvOrProfileEntry(key)
72+
return profiles.getEnvOrProfileEntry(key);
7573
/*const envKey = `${environment.toUpperCase()}_${key}`;
7674
if(process.env.hasOwnProperty(envKey)) {
7775
return process.env[envKey];
@@ -161,12 +159,12 @@ const airCanadaConfig = {
161159
}
162160
};
163161
const amadeusGdsConfig = { //TEST
164-
clientId: getConfigKey('AMADEUS_ENT_CLIENT_ID') ,
162+
clientId: getConfigKey('AMADEUS_ENT_CLIENT_ID'),
165163
clientSecret: getConfigKey('AMADEUS_ENT_CLIENT_SECRET'),
166164
hostname: getConfigKey('AMADEUS_ENT_ENVIRONMENT') || 'test'
167165
};
168166
const amadeusSelfServiceConfig = { //TEST
169-
clientId: getConfigKey('AMADEUS_SS_CLIENT_ID') ,
167+
clientId: getConfigKey('AMADEUS_SS_CLIENT_ID'),
170168
clientSecret: getConfigKey('AMADEUS_SS_CLIENT_SECRET'),
171169
hostname: getConfigKey('AMADEUS_SS_ENVIRONMENT') || 'test'
172170
};

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"dependencies": {
3434
"@elastic/elasticsearch": "7.8.0",
35-
"@windingtree/config-profiles": "^1.0.6",
35+
"@windingtree/config-profiles": "^1.0.8",
3636
"@windingtree/org.id": "1.1.0",
3737
"@windingtree/org.id-lif-deposit": "1.0.2",
3838
"@windingtree/org.id-resolver": "1.4.0",

scripts/profiles/cli.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Snippet to encrypt/decrypt entries that need to be stored in profile collection in mongo (configuration profiles)
3+
*
4+
*/
5+
const profiles = require('@windingtree/config-profiles');
6+
profiles.executeCLI(process.argv);

scripts/profiles/encrypt.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Snippet to encrypt/decrypt entries that need to be stored in profile collection in mongo (configuration profiles)
3+
*
4+
*/
5+
const profiles = require('@windingtree/config-profiles');
6+
const encryptionDetails = process.env.STAGING_PROFILE_SECRET;
7+
8+
console.log('Args:', process.argv);
9+
if (process.argv.length <= 2) {
10+
console.log('Missing argument');
11+
return;
12+
}
13+
let value = process.argv[2];
14+
15+
let encrypted = profiles.encryptText(encryptionDetails, value);
16+
let decrypted = profiles.decryptText(encryptionDetails, encrypted);
17+
console.log('value to be encrypted:', value);
18+
console.log('value after encryption:', encrypted);
19+
console.log('decrypted again:', decrypted);

vercel.json

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -102,68 +102,17 @@
102102
}
103103
],
104104
"env": {
105-
"AF_API_KEY": "@af_api_key",
106-
107-
"AC_API_KEY": "@staging.glider-aggregator.ac_api_key",
108-
"AC_USERNAME": "@staging.glider-aggregator.ac_username",
109-
"AC_PASSWORD": "@staging.glider-aggregator.ac_password",
110-
"AC_POS_COUNTRY_CODE": "@staging.glider-aggregator.ac_pos_country",
111-
"PRODUCTION_AC_API_KEY": "@production.glider-aggregator.ac_api_key",
112-
"PRODUCTION_AC_USERNAME": "@production.glider-aggregator.ac_username",
113-
"PRODUCTION_AC_PASSWORD": "@production.glider-aggregator.ac_password",
114-
"PRODUCTION_AC_POS_COUNTRY_CODE": "@production.glider-aggregator.ac_pos_country",
115-
116-
"STAGING_EREVMAX_RESERVATION_URL": "@staging.glider-aggregator.erevmax_reservation_url",
117-
"STAGING_EREVMAX_AVAILABILITY_URL": "@staging.glider-aggregator.erevmax_availability_url",
118-
"STAGING_EREVMAX_CANCELLATION_URL": "@staging.glider-aggregator.erevmax_cancellation_url",
119-
"PRODUCTION_EREVMAX_RESERVATION_URL": "@production.glider-aggregator.erevmax_reservation_url",
120-
"PRODUCTION_EREVMAX_AVAILABILITY_URL": "@production.glider-aggregator.erevmax_availability_url",
121-
"PRODUCTION_EREVMAX_CANCELLATION_URL": "@production.glider-aggregator.erevmax_cancellation_url",
122-
123-
"SIMARD_JWT": "@staging.glider-aggregator.jwt",
124-
"GLIDER_ORGID": "@staging.glider-aggregator.orgid",
125-
"GLIDER_ADMIN_KEY": "@staging.glider-aggregator.admin-key",
126-
"LIF_MIN_DEPOSIT": "@staging.glider-aggregator.lif_deposit",
127-
"PRODUCTION_SIMARD_JWT": "@production.glider-aggregator.jwt",
128-
"PRODUCTION_GLIDER_ORGID": "@production.glider-aggregator.orgid",
129-
"PRODUCTION_GLIDER_ADMIN_KEY": "@production.glider-aggregator.admin-key",
130-
"PRODUCTION_LIF_MIN_DEPOSIT": "@production.glider-aggregator.lif_deposit",
131-
132-
133-
"REDIS_URL": "@staging.glider-aggregator.redis_url",
134105
"MONGO_URL": "@staging.glider-aggregator.mongo_url",
135-
"ELASTIC_URL": "@staging.glider-aggregator.elastic_url",
136-
"INFURA_ENDPOINT": "@staging.infura_wss_endpoint",
137-
"PRODUCTION_REDIS_URL": "@production.glider-aggregator.redis_url",
138106
"PRODUCTION_MONGO_URL": "@production.glider-aggregator.mongo_url",
139-
"PRODUCTION_ELASTIC_URL": "@production.glider-aggregator.elastic_url",
140-
"PRODUCTION_INFURA_ENDPOINT": "@production.infura_wss_endpoint",
141-
"INFURA_PROJECT_ID": "@infura_project_id",
142-
143-
"ETHEREUM_NETWORK": "@staging.ethereum_network",
144-
"PRODUCTION_ETHEREUM_NETWORK": "@production.ethereum_network",
145-
146-
"STAGING_AMADEUS_SS_CLIENT_ID": "@staging.glider-aggregator.amadeus_ss_client_id",
147-
"STAGING_AMADEUS_SS_CLIENT_SECRET": "@staging.glider-aggregator.amadeus_ss_client_secret",
148-
"STAGING_AMADEUS_SS_ENVIRONMENT": "@staging.glider-aggregator.amadeus_ss_environment",
149-
150-
"PRODUCTION_AMADEUS_SS_CLIENT_ID": "@production.glider-aggregator.amadeus_ss_client_id",
151-
"PRODUCTION_AMADEUS_SS_CLIENT_SECRET": "@production.glider-aggregator.amadeus_ss_client_secret",
152-
"PRODUCTION_AMADEUS_SS_ENVIRONMENT": "@production.glider-aggregator.amadeus_ss_environment",
153-
154-
"STAGING_AMADEUS_ENT_CLIENT_ID": "@staging.glider-aggregator.amadeus_ent_client_id",
155-
"STAGING_AMADEUS_ENT_CLIENT_SECRET": "@staging.glider-aggregator.amadeus_ent_client_secret",
156-
"STAGING_AMADEUS_ENT_ENVIRONMENT": "@staging.glider-aggregator.amadeus_ent_environment",
157-
158-
159-
160-
"STAGING_BUSINESS_RULES_MONGO_URL": "@staging.glider-aggregator.business_rules_mongo_url",
161-
"PRODUCTION_BUSINESS_RULES_MONGO_URL": "@production.glider-aggregator.business_rules_mongo_url"
107+
"STAGING_PROFILE_SECRET": "@staging.glider-aggregator.profile_secret",
108+
"PRODUCTION_PROFILE_SECRET": "@production.glider-aggregator.profile_secret"
162109
},
163110
"build": {
164111
"env": {
165-
"STAGING_BUSINESS_RULES_MONGO_URL": "@staging.glider-aggregator.business_rules_mongo_url",
166-
"PRODUCTION_BUSINESS_RULES_MONGO_URL": "@production.glider-aggregator.business_rules_mongo_url"
112+
"MONGO_URL": "@staging.glider-aggregator.mongo_url",
113+
"PRODUCTION_MONGO_URL": "@production.glider-aggregator.mongo_url",
114+
"STAGING_PROFILE_SECRET": "@staging.glider-aggregator.profile_secret",
115+
"PRODUCTION_PROFILE_SECRET": "@production.glider-aggregator.profile_secret"
167116
}
168117
}
169118
}

0 commit comments

Comments
 (0)