Minor style fixes.
This commit is contained in:
parent
20679a62fd
commit
37e5bcad61
@ -29,14 +29,14 @@ plugins:
|
|||||||
# Path to CA certificates to use when connecting to
|
# Path to CA certificates to use when connecting to
|
||||||
# SSL-secured LDAP servers. If not specified, it will use
|
# SSL-secured LDAP servers. If not specified, it will use
|
||||||
# a default set of well-known CAs.
|
# a default set of well-known CAs.
|
||||||
ca_certificates:
|
certificateAuthorities:
|
||||||
- /path/to/ca_cert.pem
|
- /path/to/ca_cert.pem
|
||||||
- /path/to/another/ca_cert.pem
|
- /path/to/another/ca_cert.pem
|
||||||
|
|
||||||
# Check the validity of the server's certificate. Useful
|
# Check the validity of the server's certificate. Useful
|
||||||
# when connecting to servers that use a self-signed certificate.
|
# when connecting to servers that use a self-signed certificate.
|
||||||
# Defaults to true if not specified.
|
# Defaults to true if not specified.
|
||||||
check_certificate: true
|
checkCertificate: true
|
||||||
|
|
||||||
# Credentials to use before looking for the user record.
|
# Credentials to use before looking for the user record.
|
||||||
#
|
#
|
||||||
|
@ -4,6 +4,7 @@ import Bluebird, {coroutine, promisify} from 'bluebird'
|
|||||||
import eventToPromise from 'event-to-promise'
|
import eventToPromise from 'event-to-promise'
|
||||||
import {createClient} from 'ldapjs'
|
import {createClient} from 'ldapjs'
|
||||||
import {escape} from 'ldapjs/lib/filters/escape'
|
import {escape} from 'ldapjs/lib/filters/escape'
|
||||||
|
import {readFileSync} from 'fs'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@ -27,23 +28,27 @@ class AuthLdap {
|
|||||||
const clientOpts = {
|
const clientOpts = {
|
||||||
url: conf.uri,
|
url: conf.uri,
|
||||||
maxConnections: 5,
|
maxConnections: 5,
|
||||||
tlsOptions: { }
|
tlsOptions: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const {bind} = conf
|
const {
|
||||||
|
bind,
|
||||||
|
checkCertificate = true,
|
||||||
|
certificateAuthorities
|
||||||
|
} = conf
|
||||||
|
|
||||||
if (bind) {
|
if (bind) {
|
||||||
clientOpts.bindDN = bind.dn
|
clientOpts.bindDN = bind.dn
|
||||||
clientOpts.bindCredentials = bind.password
|
clientOpts.bindCredentials = bind.password
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (conf.check_certificate !== undefined) {
|
const {tlsOptions} = clientOpts
|
||||||
clientOpts.tlsOptions.rejectUnauthorized = conf.check_certificate
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf.ca_certificates !== undefined) {
|
tlsOptions.rejectUnauthorized = !checkCertificate
|
||||||
clientOpts.tlsOptions.ca = conf.ca_certificates
|
if (certificateAuthorities) {
|
||||||
|
tlsOptions.ca = certificateAuthorities.map(path => readFileSync(path))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const {base: searchBase} = conf
|
const {base: searchBase} = conf
|
||||||
|
Loading…
Reference in New Issue
Block a user