Skip to content

Commit

Permalink
do not read config.json if OVERRIDE_CONFIG=false
Browse files Browse the repository at this point in the history
  • Loading branch information
jfromaniello committed Mar 21, 2016
1 parent 53065f1 commit 8b80e88
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 40 deletions.
3 changes: 1 addition & 2 deletions connector-setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ exports.run = function (workingPath, callback) {
provisioningTicket = pt;
cb();
});
},
function (cb) {
}, function (cb) {
var info_url = urlJoin(provisioningTicket, '/info');
console.log('Loading settings from ticket: ' + info_url);

Expand Down
82 changes: 44 additions & 38 deletions lib/initConf.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
var nconf = require('nconf');
var defaults = {
PORT: 4000,
SESSION_SECRET: 'a1b2c3d4567',
AUTHENTICATION: 'FORM',
LDAP_SEARCH_QUERY: '(&(objectCategory=person)(anr={0}))',
LDAP_SEARCH_ALL_QUERY: '(objectCategory=person)',
LDAP_SEARCH_GROUPS: '(member:1.2.840.113556.1.4.1941:={0})',
LDAP_USER_BY_NAME: '(sAMAccountName={0})',
WSFED_ISSUER: 'urn:auth0',
AGENT_MODE: true,
GROUPS: true,
LDAP_HEARTBEAT_SECONDS: 60,
GROUPS_TIMEOUT_SECONDS: 20,
GROUP_PROPERTY: 'cn',
GROUPS_CACHE_SECONDS: 600,
ALLOW_PASSWORD_EXPIRED: false,
ALLOW_PASSWORD_CHANGE_REQUIRED: false,
OVERRIDE_CONFIG: true,
CACHE_FILE: __dirname + '/../cache.db'
};

nconf.env('||')
.file({
file: __dirname + '/../config.json',
logicalSeparator: '||',
format: {
parse: function (content) {
return JSON.parse(content);
},
stringify: function (content){
var result = JSON.stringify(content, null, 2);
if (process.platform === 'win32') {
result = result.replace(/\n/ig, "\r\n");
}
return result;
}
}
})
.env()
.defaults({
PORT: 4000,
SESSION_SECRET: 'a1b2c3d4567',
AUTHENTICATION: 'FORM',
LDAP_SEARCH_QUERY: '(&(objectCategory=person)(anr={0}))',
LDAP_SEARCH_ALL_QUERY: '(objectCategory=person)',
LDAP_SEARCH_GROUPS: '(member:1.2.840.113556.1.4.1941:={0})',
LDAP_USER_BY_NAME: '(sAMAccountName={0})',
WSFED_ISSUER: 'urn:auth0',
AGENT_MODE: true,
GROUPS: true,
LDAP_HEARTBEAT_SECONDS: 60,
GROUPS_TIMEOUT_SECONDS: 20,
GROUP_PROPERTY: 'cn',
GROUPS_CACHE_SECONDS: 600,
ALLOW_PASSWORD_EXPIRED: false,
ALLOW_PASSWORD_CHANGE_REQUIRED: false,
OVERRIDE_CONFIG: true,
CACHE_FILE: __dirname + '/../cache.db'
});
if (process.env.OVERRIDE_CONFIG === 'false') {
nconf.overrides({ OVERRIDE_CONFIG: false })
.env('||')
.defaults(defaults);
} else {
nconf.env('||')
.file({
file: __dirname + '/../config.json',
logicalSeparator: '||',
format: {
parse: function (content) {
return JSON.parse(content);
},
stringify: function (content){
var result = JSON.stringify(content, null, 2);
if (process.platform === 'win32') {
result = result.replace(/\n/ig, "\r\n");
}
return result;
}
}
})
.defaults(defaults);
}

0 comments on commit 8b80e88

Please sign in to comment.