LDAP - allow specifying certificate file
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2021-03-10 18:22:51 -06:00
parent e6a7070589
commit 6a4f82611b
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
2 changed files with 12 additions and 1 deletions

View File

@ -2,6 +2,7 @@ const Unit = require('libflitter/Unit')
const LDAP = require('ldapjs')
const Validator = require('email-validator')
const net = require('net')
const fs = require('fs')
// TODO support logging ALL ldap requests when in DEBUG, not just routed ones
// TODO need to support LDAP server auto-discovery/detection features
@ -77,7 +78,11 @@ class LDAPServerUnit extends Unit {
// If Flitter is configured to use an SSL certificate,
// use it to enable LDAPS in the server.
if ( this.express.use_ssl() ) {
if ( this.config.ssl?.enable ) {
this.output.info('Using configured SSL certificate. The LDAP server will require an ldaps:// connection.')
server_config.certificate = fs.readFileSync(this.config.ssl.certificate)
server_config.key = fs.readFileSync(this.config.ssl.key)
} else if ( this.express.use_ssl() ) {
this.output.info('Using configured SSL certificate. The LDAP server will require an ldaps:// connection.')
server_config.certificate = await this.express.ssl_certificate()
server_config.key = await this.express.ssl_key()

View File

@ -5,6 +5,12 @@ const ldap_server = {
max_connections: env('LDAP_MAX_CONNECTIONS'),
interface: env('LDAP_LISTEN_INTERFACE', '0.0.0.0'),
ssl: {
enable: env('LDAP_SSL_ENABLE', false),
certificate: env('LDAP_CERT_PATH'),
key: env('LDAP_CERT_KEY_PATH'),
},
schema: {
base_dc: env('LDAP_BASE_DC', 'dc=example,dc=com'),
authentication_base: env('LDAP_AUTH_BASE', 'ou=people'),