Minor style fixes.

This commit is contained in:
Julien Fontanet 2015-04-18 12:37:02 +02:00
parent 20679a62fd
commit 37e5bcad61
2 changed files with 17 additions and 12 deletions

View File

@ -29,14 +29,14 @@ plugins:
# Path to CA certificates to use when connecting to
# SSL-secured LDAP servers. If not specified, it will use
# a default set of well-known CAs.
ca_certificates:
- /path/to/ca_cert.pem
- /path/to/another/ca_cert.pem
certificateAuthorities:
- /path/to/ca_cert.pem
- /path/to/another/ca_cert.pem
# Check the validity of the server's certificate. Useful
# when connecting to servers that use a self-signed certificate.
# Defaults to true if not specified.
check_certificate: true
checkCertificate: true
# Credentials to use before looking for the user record.
#

View File

@ -4,6 +4,7 @@ import Bluebird, {coroutine, promisify} from 'bluebird'
import eventToPromise from 'event-to-promise'
import {createClient} from 'ldapjs'
import {escape} from 'ldapjs/lib/filters/escape'
import {readFileSync} from 'fs'
// ===================================================================
@ -27,23 +28,27 @@ class AuthLdap {
const clientOpts = {
url: conf.uri,
maxConnections: 5,
tlsOptions: { }
tlsOptions: {}
}
{
const {bind} = conf
const {
bind,
checkCertificate = true,
certificateAuthorities
} = conf
if (bind) {
clientOpts.bindDN = bind.dn
clientOpts.bindCredentials = bind.password
}
}
if (conf.check_certificate !== undefined) {
clientOpts.tlsOptions.rejectUnauthorized = conf.check_certificate
}
const {tlsOptions} = clientOpts
if (conf.ca_certificates !== undefined) {
clientOpts.tlsOptions.ca = conf.ca_certificates
tlsOptions.rejectUnauthorized = !checkCertificate
if (certificateAuthorities) {
tlsOptions.ca = certificateAuthorities.map(path => readFileSync(path))
}
}
const {base: searchBase} = conf