Skip to content

Commit c560eaf

Browse files
authored
Merge pull request #80 from apigee-internal/custom-auth-uri-fixes
Formatting the url before handing it off to the cert lib.
2 parents d0ed758 + 8278270 commit c560eaf

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ tests/cache-config.yaml
4141
tmp-*
4242
default.yaml.bak
4343
*-*-*config.yaml
44-
test-token.txt
44+
test-token.txt
45+
env.sh

cli/lib/cert-lib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ function isApigeeError(err, code) {
393393

394394
function getPublicKey(organization, environment, authUri,cb) {
395395

396-
const uri = util.format(authUri + '/publicKey', organization, environment);
396+
const uri = authUri + '/publicKey';
397397
request({
398398
uri: uri,
399399
}, function(err, res) {

cli/lib/cert.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,23 @@ Cert.prototype.installCert = function(options, cb) {
4444

4545
Cert.prototype.checkCert = function(options, cb) {
4646

47-
48-
4947
assert(options.org,"org is required");
5048
assert(options.env,"env is required")
5149

5250
assert(options.username,"username is required");
5351
assert(options.password,"password is required")
5452

5553
const config = edgeconfig.load({ source: configLocations.getSourcePath(options.org, options.env) });
54+
if (options.url) {
55+
if (options.url.indexOf('://') === -1) {
56+
options.url = 'https://' + options.url;
57+
}
58+
config.edge_config.authUri = options.url + '/edgemicro-auth';
59+
} else {
60+
var newAuthURI = util.format(config.edge_config.authUri, options.org, options.env);
61+
config.edge_config.authUri = newAuthURI;
62+
}
63+
5664
cert(config).checkCertWithPassword(options, (err, res) => {
5765
if (err) {
5866
if(cb){
@@ -94,6 +102,15 @@ Cert.prototype.retrievePublicKey = function(options,cb) {
94102
assert(options.env,"env is required")
95103

96104
const config = edgeconfig.load({ source: configLocations.getSourcePath(options.org, options.env) });
105+
if (options.url) {
106+
if (options.url.indexOf('://') === -1) {
107+
options.url = 'https://' + options.url;
108+
}
109+
config.edge_config.authUri = options.url + '/edgemicro-auth';
110+
} else {
111+
var newAuthURI = util.format(config.edge_config.authUri, options.org, options.env);
112+
config.edge_config.authUri = newAuthURI;
113+
}
97114
cert(config).retrievePublicKey(options, (err, certificate) => {
98115
if (err) {
99116
cb && cb(err);
@@ -133,4 +150,4 @@ function printError(err) {
133150
} else {
134151
console.log(err);
135152
}
136-
}
153+
}

cli/lib/configure.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Configure.prototype.configure = function configure(options, cb) {
5050
options.url = 'https://' + options.url;
5151
}
5252
defaultConfig.edge_config.authUri = options.url + '/edgemicro-auth';
53+
} else {
54+
var newAuthURI = util.format(defaultConfig.edge_config.authUri, options.org, options.env);
55+
defaultConfig.edge_config.authUri = newAuthURI;
5356
}
5457

5558
authUri = defaultConfig.edge_config.authUri;
@@ -153,8 +156,7 @@ function configureEdgemicroWithCreds(options, cb) {
153156
agentConfig['edge_config']['jwt_public_key'] = results[0]; // get deploy results
154157
agentConfig['edge_config'].bootstrap = results[2].bootstrap; // get genkeys results
155158
} else {
156-
agentConfig['edge_config']['jwt_public_key'] =
157-
options.url ? authUri + '/publicKey' : util.format(authUri + '/publicKey', options.org, options.env);
159+
agentConfig['edge_config']['jwt_public_key'] = authUri + '/publicKey';
158160
agentConfig['edge_config'].bootstrap = results[1].bootstrap;
159161
}
160162

0 commit comments

Comments
 (0)