Start basic LDAP server groundwork

This commit is contained in:
garrettmills
2020-04-16 19:59:48 -05:00
parent dbdaf775df
commit 226b90b7bf
36 changed files with 971 additions and 11 deletions

21
app/unit/LDAPRegistry.js Normal file
View File

@@ -0,0 +1,21 @@
const Unit = require('libflitter/Unit')
class LDAPRegistry extends Unit {
static get name() {
return 'ldap_registry'
}
static get services() {
return [...super.services, 'output']
}
async go(app) {
}
async cleanup(app) {
}
}
module.exports = exports = LDAPRegistry

View File

@@ -0,0 +1,44 @@
const Unit = require('libflitter/Unit')
const LDAP = require('ldapjs')
class LDAPServerUnit extends Unit {
static get name() {
return 'ldap_server'
}
static get services() {
return [...super.services, 'configs', 'express', 'output']
}
async go(app) {
this.config = this.configs.get('ldap:server')
const server_config = {}
// If Flitter is configured to use an SSL certificate,
// use it to enable LDAPS in the server.
if ( this.express.use_ssl() ) {
this.output.info('[LDAP Server] Using configured SSL certificate to enable LDAPS.')
server_config.certificate = await this.express.ssl_certificate()
server_config.key = await this.express.ssl_key()
}
this.server = LDAP.createServer(server_config)
if ( this.config.max_connections ) {
this.server.maxConnections = this.config.max_connections
}
this.output.info(`[LDAP Server] Will listen on ${this.config.interface}:${this.config.port}`)
await new Promise((res, rej) => {
this.server.listen(this.config.port, this.config.interface, () => {
res()
})
})
}
async cleanup(app) {
this.server.close()
}
}
module.exports = exports = LDAPServerUnit