diff --git a/.gitignore b/.gitignore index fa8896a..70e39a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store node_modules **/.env -!fusionauth/.env \ No newline at end of file +!fusionauth/.env +!tenant/.env \ No newline at end of file diff --git a/tenant/.env b/tenant/.env new file mode 100644 index 0000000..08e0757 --- /dev/null +++ b/tenant/.env @@ -0,0 +1,4 @@ +APP_URL=http://localhost +FA_URL=http://localhost:9011 +FA_API_KEY=33052c8a-c283-4e96-9d2a-eb1215c69f8f-not-for-prod +clientSecret=super-secret-secret-that-should-be-regenerated-for-production \ No newline at end of file diff --git a/tenant/package-lock.json b/tenant/package-lock.json index 6a5f664..d99d2be 100644 --- a/tenant/package-lock.json +++ b/tenant/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@fusionauth/node-client": "^1.48.0", + "dotenv": "^16.3.2", "prompt-sync": "^4.2.0", "uuid": "^9.0.1" } @@ -38,6 +39,17 @@ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" }, + "node_modules/dotenv": { + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz", + "integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/promise": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", @@ -97,6 +109,11 @@ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" }, + "dotenv": { + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz", + "integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==" + }, "promise": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", diff --git a/tenant/package.json b/tenant/package.json index 8edbb75..b93e0f5 100644 --- a/tenant/package.json +++ b/tenant/package.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@fusionauth/node-client": "^1.48.0", + "dotenv": "^16.3.2", "prompt-sync": "^4.2.0", "uuid": "^9.0.1" } diff --git a/tenant/tenant-creation.js b/tenant/tenant-creation.js index 1ba3ec3..cbb0252 100644 --- a/tenant/tenant-creation.js +++ b/tenant/tenant-creation.js @@ -2,10 +2,14 @@ const uuid = require('uuid'); const { FusionAuthClient } = require('@fusionauth/node-client'); const prompt = require('prompt-sync')(); const fs = require('fs'); +require('dotenv').config() -const appUrl = 'http://localhost'; -const client = new FusionAuthClient('33052c8a-c283-4e96-9d2a-eb1215c69f8f-not-for-prod', 'http://localhost:9011'); -const clientSecret = "super-secret-secret-that-should-be-regenerated-for-production"; + +const appUrl = process.env.APP_URL || 'http://localhost'; +const FA_URL = process.env.FA_URL || 'http://localhost:9011'; +const FA_API_KEY = process.env.FA_API_KEY || '33052c8a-c283-4e96-9d2a-eb1215c69f8f-not-for-prod'; +const client = new FusionAuthClient(FA_API_KEY, FA_URL); +const clientSecret = process.env.clientSecret || "super-secret-secret-that-should-be-regenerated-for-production"; async function deleteTenant(tenantName) { try { @@ -91,9 +95,13 @@ function appendTenantToIngress(tenant, port) { } async function main() { - const tenant = prompt("Tenant name (key): "); + const tenant = prompt("Tenant: "); const port = prompt("Port: "); const backgroundColor = "#" + prompt("Background-Color: #"); + if (!tenant || !port || !backgroundColor) { + console.log("Tenant, port and background-color are required"); + return; + } const { tenantId, applicationId } = await create(tenant); console.log(`Created tenant ${tenant}`); console.log(`- Tenant ID: ${tenantId}`);