Add basic LDAP bind functionality
This commit is contained in:
@@ -10,6 +10,20 @@ class LDAPServerUnit extends Unit {
|
||||
return [...super.services, 'configs', 'express', 'output']
|
||||
}
|
||||
|
||||
auth_dn() {
|
||||
return this.build_dn(this.config.schema.authentication_base)
|
||||
}
|
||||
|
||||
anonymous() {
|
||||
return LDAP.parseDN('cn=anonymous')
|
||||
}
|
||||
|
||||
build_dn(...parts) {
|
||||
parts = parts.flat()
|
||||
parts.push(this.config.schema.base_dc)
|
||||
return LDAP.parseDN(parts.join(','))
|
||||
}
|
||||
|
||||
async go(app) {
|
||||
this.config = this.configs.get('ldap:server')
|
||||
const server_config = {}
|
||||
@@ -17,7 +31,7 @@ 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() ) {
|
||||
this.output.info('[LDAP Server] Using configured SSL certificate to enable LDAPS.')
|
||||
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()
|
||||
}
|
||||
@@ -28,9 +42,10 @@ class LDAPServerUnit extends Unit {
|
||||
this.server.maxConnections = this.config.max_connections
|
||||
}
|
||||
|
||||
this.output.info(`[LDAP Server] Will listen on ${this.config.interface}:${this.config.port}`)
|
||||
this.output.info(`Will listen on ${this.config.interface}:${this.config.port}`)
|
||||
await new Promise((res, rej) => {
|
||||
this.server.listen(this.config.port, this.config.interface, () => {
|
||||
this.output.success(`LDAP server listening on port ${this.config.port}...`)
|
||||
res()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user