Merge pull request #180 from trentm/cli-insecure-option

add '-i, --insecure' option and LDAPJS_TLS_INSECURE=1 envvar support to all ldapjs-* CLIs
This commit is contained in:
Mark Cavage 2014-04-22 17:58:46 -07:00
commit cf8adf4a4a
5 changed files with 75 additions and 5 deletions

View File

@ -25,6 +25,7 @@ var opts = {
'debug': Number,
'binddn': ldap.DN,
'file': String,
'insecure': Boolean,
'password': String,
'url': url
};
@ -33,6 +34,7 @@ var shortOpts = {
'd': ['--debug'],
'D': ['--binddn'],
'f': ['--file'],
'i': ['--insecure'],
'w': ['--password'],
'u': ['--url']
};
@ -90,6 +92,15 @@ try {
usage(1, e.toString());
}
if (parsed.insecure === undefined &&
process.env.LDAPJS_TLS_INSECURE !== undefined) {
if (process.env.LDAPJS_TLS_INSECURE === '0') {
parsed.insecure = false;
} else {
parsed.insecure = true;
}
}
if (parsed.help)
usage(0);
if (!parsed.file) {
@ -127,7 +138,10 @@ var log = new Logger({
var client = ldap.createClient({
url: parsed.url,
log: log
log: log,
tlsOptions: {
rejectUnauthorized: !parsed.insecure
}
});
client.on('error', function(err) {

View File

@ -26,6 +26,7 @@ var opts = {
'debug': Number,
'binddn': ldap.DN,
'file': String,
'insecure': Boolean,
'password': String,
'url': url,
'value': String,
@ -36,6 +37,7 @@ var shortOpts = {
'd': ['--debug'],
'D': ['--binddn'],
'f': ['--file'],
'i': ['--insecure'],
'w': ['--password'],
'u': ['--url'],
'v': ['--value']
@ -89,6 +91,15 @@ try {
usage(1, e.toString());
}
if (parsed.insecure === undefined &&
process.env.LDAPJS_TLS_INSECURE !== undefined) {
if (process.env.LDAPJS_TLS_INSECURE === '0') {
parsed.insecure = false;
} else {
parsed.insecure = true;
}
}
if (parsed.help)
usage(0);
@ -123,7 +134,10 @@ var log = new Logger({
var client = ldap.createClient({
url: parsed.url,
log: log
log: log,
tlsOptions: {
rejectUnauthorized: !parsed.insecure
}
});
client.on('error', function(err) {

View File

@ -24,6 +24,7 @@ nopt.typeDefs.DN = {
var opts = {
'debug': Number,
'binddn': ldap.DN,
'insecure': Boolean,
'password': String,
'url': url
};
@ -31,6 +32,7 @@ var opts = {
var shortOpts = {
'd': ['--debug'],
'D': ['--binddn'],
'i': ['--insecure'],
'w': ['--password'],
'u': ['--url']
};
@ -83,6 +85,15 @@ try {
usage(1, e.toString());
}
if (parsed.insecure === undefined &&
process.env.LDAPJS_TLS_INSECURE !== undefined) {
if (process.env.LDAPJS_TLS_INSECURE === '0') {
parsed.insecure = false;
} else {
parsed.insecure = true;
}
}
if (parsed.help)
usage(0);
if (parsed.argv.remain.length < 1)
@ -113,7 +124,10 @@ var log = new Logger({
var client = ldap.createClient({
url: parsed.url,
log: log
log: log,
tlsOptions: {
rejectUnauthorized: !parsed.insecure
}
});
client.on('error', function(err) {

View File

@ -26,6 +26,7 @@ var opts = {
'debug': Number,
'binddn': ldap.DN,
'file': String,
'insecure': Boolean,
'password': String,
'type': String,
'url': url,
@ -37,6 +38,7 @@ var shortOpts = {
'd': ['--debug'],
'D': ['--binddn'],
'f': ['--file'],
'i': ['--insecure'],
'w': ['--password'],
't': ['--type'],
'u': ['--url'],
@ -91,6 +93,15 @@ try {
usage(1, e.toString());
}
if (parsed.insecure === undefined &&
process.env.LDAPJS_TLS_INSECURE !== undefined) {
if (process.env.LDAPJS_TLS_INSECURE === '0') {
parsed.insecure = false;
} else {
parsed.insecure = true;
}
}
if (parsed.help)
usage(0);
@ -127,7 +138,10 @@ var log = new Logger({
var client = ldap.createClient({
url: parsed.url,
log: log
log: log,
tlsOptions: {
rejectUnauthorized: !parsed.insecure
}
});
client.on('error', function(err) {

View File

@ -33,6 +33,7 @@ var opts = {
'base': ldap.DN,
'binddn': ldap.DN,
'control': Array,
'insecure': Boolean,
'password': String,
'persistent': Boolean,
'paged': Number,
@ -46,6 +47,7 @@ var shortOpts = {
'd': ['--debug'],
'b': ['--base'],
'D': ['--binddn'],
'i': ['--insecure'],
'w': ['--password'],
'p': ['--persistent'],
'g': ['--paged'],
@ -101,6 +103,15 @@ try {
usage(1, e.toString());
}
if (parsed.insecure === undefined &&
process.env.LDAPJS_TLS_INSECURE !== undefined) {
if (process.env.LDAPJS_TLS_INSECURE === '0') {
parsed.insecure = false;
} else {
parsed.insecure = true;
}
}
if (parsed.help)
usage(0);
if (parsed.argv.remain.length < 1)
@ -139,7 +150,10 @@ var log = new Logger({
var client = ldap.createClient({
url: parsed.url,
log: log,
timeout: parsed.timeout || false
timeout: parsed.timeout || false,
tlsOptions: {
rejectUnauthorized: !parsed.insecure
}
});
client.on('error', function(err) {