From 5396b27ffad2b49a8134b61832c2c031062f1c48 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Jan 2021 16:26:56 +0100 Subject: [PATCH] Ldap styling --- peertube-plugin-auth-ldap/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/peertube-plugin-auth-ldap/main.js b/peertube-plugin-auth-ldap/main.js index 9b9f115..d1ff240 100644 --- a/peertube-plugin-auth-ldap/main.js +++ b/peertube-plugin-auth-ldap/main.js @@ -1,5 +1,5 @@ const LdapAuth = require('ldapauth-fork') -const fs = require('fs'); +const fs = require('fs') const store = { weight: 100 @@ -177,7 +177,7 @@ async function login (peertubeHelpers, settingsManager, options) { return null } - let clientOpts = { + const clientOpts = { url: settings['url'], bindDN: settings['bind-dn'], bindCredentials: settings['bind-credentials'], @@ -189,17 +189,17 @@ async function login (peertubeHelpers, settingsManager, options) { tlsOptions: { rejectUnauthorized: settings['insecure-tls'] !== true } - }; + } + if (settings['custom-ca'] && settings['insecure-tls'] !== true) { try { - let cadata = fs.readFileSync(settings['custom-ca']); - clientOpts.tlsOptions['ca'] = [ cadata ]; - } catch (nvm) { - logger.warn('Could not load custom CA in LDAP plugin', { nvm }); + clientOpts.tlsOptions['ca'] = [ await fs.readFile(settings['custom-ca']) ] + } catch (err) { + logger.warn('Could not load custom CA in LDAP plugin', { err }) } } - const ldapClient = new LdapAuth(clientOpts); + const ldapClient = new LdapAuth(clientOpts) return new Promise(res => { function onError (err) {