edgemicro
Advanced tools
Comparing version 2.5.20-beta to 2.5.21-beta
@@ -132,2 +132,6 @@ 'use strict'; | ||
.option('-u, --configUrl <configUrl>', 'Provide the endpoint to download the edgemicro config file') | ||
.option('-a, --apiProxyName <apiProxyName>', 'the api proxy name; must be used with env var EDGEMICRO_LOCAL') | ||
.option('-v, --revision <revision>', 'api proxy revision; required if apiProxyName is set') | ||
.option('-b, --basepath <basepath>', 'api proxy basePath; required if apiProxyName is set') | ||
.option('-t, --target <target>', 'target endpoint for proxy; required if apiProxyName is set') | ||
.description('start the gateway based on configuration') | ||
@@ -143,3 +147,10 @@ .action((options) => { | ||
options.configUrl = options.configUrl || process.env.EDGEMICRO_CONFIG_URL; | ||
options.apiProxyName = options.apiProxyName || process.env.EDGEMICRO_API_PROXYNAME; | ||
options.revision = options.revision || process.env.EDGEMICRO_API_REVISION; | ||
options.basepath = options.basepath || process.env.EDGEMICRO_API_BASEPATH; | ||
options.target = options.target || process.env.EDGEMICRO_API_TARGET; | ||
debug("EDGEMICRO_LOCAL: " + process.env.EDGEMICRO_LOCAL) | ||
debug("EDGEMICRO_LOCAL_PROXY: " + process.env.EDGEMICRO_LOCAL_PROXY) | ||
if (options.port) { | ||
@@ -155,6 +166,6 @@ portastic.test(options.port) | ||
} | ||
if (!options.key) { | ||
if (!options.key && !process.env.EDGEMICRO_LOCAL) { | ||
return options.error('key is required'); | ||
} | ||
if (!options.secret) { | ||
if (!options.secret && !process.env.EDGEMICRO_LOCAL) { | ||
return options.error('secret is required'); | ||
@@ -168,2 +179,30 @@ } | ||
} | ||
if (options.apiProxyName || options.target || options.revision || options.basepath || process.env.EDGEMICRO_LOCAL || process.env.EDGEMICRO_LOCAL_PROXY) { | ||
//if any of these are set, look for environment variable | ||
if (!process.env.EDGEMICRO_LOCAL && !process.env.EDGEMICRO_LOCAL_PROXY) { | ||
return options.error('set the EDGEMICRO_LOCAL or EDGEMICRO_LOCAL_PROXY variable for apiProxyName parameter'); | ||
process.exit(1); | ||
} else if (process.env.EDGEMICRO_LOCAL && process.env.EDGEMICRO_LOCAL_PROXY) { | ||
return options.error('set the EDGEMICRO_LOCAL or EDGEMICRO_LOCAL_PROXY; not both'); | ||
process.exit(1); | ||
} else { | ||
if (options.apiProxyName && options.target && options.revision && options.basepath) { | ||
if (!validateUrl(options.target)) { | ||
return options.error('target endpoint not a valid url'); | ||
process.exit(1); | ||
} | ||
if (process.env.EDGEMICRO_LOCAL) { | ||
//create fake credentials - not used anywhere | ||
options.key = 'dummy'; | ||
options.secret = 'dummy'; | ||
} | ||
//start gateway | ||
run.start(options); | ||
return; | ||
} else { | ||
return options.error('apiProxyName, target, revision and basepath are all mandatory parms when EDGEMICRO_LOCAL or EDGEMICRO_LOCAL_PROXY is set'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
if (options.configUrl) { | ||
@@ -199,3 +238,5 @@ options.configDir = options.configDir || os.homedir() + "/" + ".edgemicro"; | ||
} | ||
} else run.start(options); | ||
} else { | ||
run.start(options); | ||
} | ||
}); | ||
@@ -360,4 +401,4 @@ | ||
.option('-p, --password <password>', 'password of the organization admin') | ||
.option('-k, --key <key>', 'Microgateway Key to be revoked') | ||
.option('-s, --secret <secret>', 'Microgateway secret to be revoked') | ||
.option('-k, --key <key>', 'Microgateway Key to be revoked') | ||
.option('-s, --secret <secret>', 'Microgateway secret to be revoked') | ||
.description('revoke authentication keys for runtime auth between Microgateway and Edge') | ||
@@ -480,2 +521,31 @@ .action((options) => { | ||
commander | ||
.command('clean') | ||
.option('-o, --org <org>', 'the organization') | ||
.option('-e, --env <env>', 'the environment') | ||
.option('-u, --username <user>', 'username of the organization admin') | ||
.option('-p, --password <password>', 'password of the organization admin') | ||
.description('clean up microgateway artifacts from the org') | ||
.action((options) => { | ||
options.error = optionError; | ||
if (!options.username) { | ||
return options.error('username is required'); | ||
} | ||
if (!options.org) { | ||
return options.error('org is required'); | ||
} | ||
if (!options.env) { | ||
return options.error('env is required'); | ||
} | ||
if (!options.kid) { | ||
return options.error('kid is required'); | ||
} | ||
promptForPassword(options, (options) => { | ||
if (!options.password) { | ||
return options.error('password is required'); | ||
} | ||
//TODO | ||
}) | ||
}); | ||
commander.parse(process.argv); | ||
@@ -513,3 +583,13 @@ | ||
//check url format | ||
function validateUrl(target) { | ||
try { | ||
url.parse(target, true); | ||
return true; | ||
} catch (err) { | ||
console.error("Malformed URL: " + err); | ||
return false; | ||
} | ||
} | ||
module.exports = setup; |
@@ -52,5 +52,13 @@ 'use strict'; | ||
const localproxy = { | ||
apiProxyName: options.apiProxyName, | ||
revision: options.revision, | ||
basePath: options.basepath, | ||
targetEndpoint: options.target | ||
}; | ||
edgeconfig.get({ | ||
source: source, | ||
keys: keys | ||
keys: keys, | ||
localproxy: localproxy | ||
}, (err, config) => { | ||
@@ -57,0 +65,0 @@ if (err) { |
@@ -104,6 +104,6 @@ | ||
cb && cb(err) | ||
return printError(err) | ||
return printError(err); | ||
} | ||
console.log(res.body) | ||
cb && cb(null, res.body) | ||
console.log(JSON.stringify(res.body, null, 2)); | ||
cb && cb(null, res.body); | ||
}); | ||
@@ -110,0 +110,0 @@ } |
{ | ||
"name": "edgemicro", | ||
"version": "2.5.20-beta", | ||
"version": "2.5.21-beta", | ||
"lockfileVersion": 1 | ||
} |
{ | ||
"name": "edgemicro", | ||
"version": "2.5.20-beta", | ||
"version": "2.5.21-beta", | ||
"description": "Apigee Edge Microgateway", | ||
@@ -27,6 +27,6 @@ "main": "index.js", | ||
"memored": "^1.1.1", | ||
"microgateway-config": "2.4.9-beta", | ||
"microgateway-core": "2.5.12-beta", | ||
"microgateway-config": "2.4.10-beta", | ||
"microgateway-core": "2.5.13-beta", | ||
"microgateway-edgeauth": "^2.4.0", | ||
"microgateway-plugins": "2.3.25-beta", | ||
"microgateway-plugins": "2.3.26-beta", | ||
"pem": "^1.8.1", | ||
@@ -33,0 +33,0 @@ "portastic": "^1.0.1", |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
241632
65
4610
77
+ Addedmicrogateway-config@2.4.10-beta(transitive)
+ Addedmicrogateway-core@2.5.13-beta(transitive)
+ Addedmicrogateway-plugins@2.3.26-beta(transitive)
- Removedmicrogateway-config@2.4.9-beta(transitive)
- Removedmicrogateway-core@2.5.12-beta(transitive)
- Removedmicrogateway-plugins@2.3.25-beta(transitive)