Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Add to settings.json:
"groupAttributeIsDN": true,
"searchScope": "sub",
"groupSearch": "(&(cn=admin)(objectClass=groupOfNames))",
"anonymousReadonly": false
"anonymousReadonly": false,
// The following is optional. You can also set it to false to ignore peer certificates
"tls_ca_file": "/path/to/yourcert.pem"
}
},

Expand Down
8 changes: 7 additions & 1 deletion ep_ldapauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ exports.authenticate = function(hook_name, context, cb) {
};

if (typeof(settings.users.ldapauth.tls_ca_file) !== 'undefined') {
myLdapAuthOpts.tls_ca = fs.readFileSync(settings.users.ldapauth.tls_ca_file);
// if parameter tls_ca_file is set to false, then ignore client certificates,
// else, use the provided PEM format certificate
if (settings.users.ldapauth.tls_ca_file == false) {
myLdapAuthOpts.tls_ca = false;
} else {
myLdapAuthOpts.tls_ca = fs.readFileSync(settings.users.ldapauth.tls_ca_file);
}
}

var authenticateLDAP = new MyLdapAuth(myLdapAuthOpts);
Expand Down
14 changes: 12 additions & 2 deletions lib/MyLdapAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ MyLdapAuth.prototype._adminBind = function (cb) {

if (typeof(self.opts.tls_ca !== 'undefined')) {
clientOpts.tlsOptions = {};
clientOpts.tlsOptions.ca = self.opts.tls_ca;
// if tls_ca is set to false, then ignore certificates, else use the provided one
if (self.opts.tls_ca == false) {
clientOpts.tlsOptions.rejectUnauthorized = false;
} else {
clientOpts.tlsOptions.ca = self.opts.tls_ca;
}
}

self._adminClient = ldap.createClient(clientOpts);
Expand Down Expand Up @@ -158,7 +163,12 @@ MyLdapAuth.prototype.authenticate = function (username, password, cb) {

if (typeof(self.opts.tls_ca !== 'undefined')) {
clientOpts.tlsOptions = {};
clientOpts.tlsOptions.ca = self.opts.tls_ca;
// if tls_ca is set to false, then ignore certificates, else use the provided one
if (self.opts.tls_ca == false) {
clientOpts.tlsOptions.rejectUnauthorized = false;
} else {
clientOpts.tlsOptions.ca = self.opts.tls_ca;
}
}

var userClient = ldap.createClient(clientOpts);
Expand Down