Add LDAPS-support to LDAP-Authcontroller (#7014)

* Add LDAPS-support to LDAP-Authcontroller

* Add Testcase that failed with valid certificate but wrong credendtials to LDAP-Authcontroller

* change scope of 'error' and remove 'case undefined', because it's not needed anymore
This commit is contained in:
Fabian Strachanski
2020-11-19 01:20:59 +01:00
committed by GitHub
parent ccb045b68c
commit c958c46fa7
6 changed files with 220 additions and 13 deletions

View File

@@ -1,7 +1,13 @@
const ldapjs = require('ldapjs');
const fs = require('fs');
function newServer(port, dn, provokeSearchError = false) {
const server = ldapjs.createServer();
const tlsOptions = {
key: fs.readFileSync(__dirname + '/support/cert/key.pem'),
certificate: fs.readFileSync(__dirname + '/support/cert/cert.pem')
}
function newServer(port, dn, provokeSearchError = false, ssl = false) {
const server = ssl ? ldapjs.createServer(tlsOptions) : ldapjs.createServer();
server.bind('o=example', function (req, res, next) {
if (req.dn.toString() !== dn || req.credentials !== 'secret')