Added secure config parameter to use ldaps protocol
This commit is contained in:
parent
ae5faadffa
commit
c8eeeaa9b9
1 changed files with 5 additions and 4 deletions
|
@ -20,7 +20,8 @@ let authMode = 'local';
|
||||||
let LdapStrategy;
|
let LdapStrategy;
|
||||||
let ldapStrategyOpts;
|
let ldapStrategyOpts;
|
||||||
if (config.ldap.enabled) {
|
if (config.ldap.enabled) {
|
||||||
if (!config.ldap.method || config.ldap.method == 'ldapjs') {
|
const ldapProtocol = config.ldap.secure ? 'ldaps' : 'ldap';
|
||||||
|
if (!config.ldap.method || config.ldap.method === 'ldapjs') {
|
||||||
try {
|
try {
|
||||||
LdapStrategy = require('passport-ldapjs').Strategy; // eslint-disable-line global-require
|
LdapStrategy = require('passport-ldapjs').Strategy; // eslint-disable-line global-require
|
||||||
authMode = 'ldapjs';
|
authMode = 'ldapjs';
|
||||||
|
@ -28,7 +29,7 @@ if (config.ldap.enabled) {
|
||||||
|
|
||||||
ldapStrategyOpts = {
|
ldapStrategyOpts = {
|
||||||
server: {
|
server: {
|
||||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port
|
url: ldapProtocol + '://' + config.ldap.host + ':' + config.ldap.port
|
||||||
},
|
},
|
||||||
base: config.ldap.baseDN,
|
base: config.ldap.baseDN,
|
||||||
search: {
|
search: {
|
||||||
|
@ -46,7 +47,7 @@ if (config.ldap.enabled) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LdapStrategy && (!config.ldap.method || config.ldap.method == 'ldapauth')) {
|
if (!LdapStrategy && (!config.ldap.method || config.ldap.method === 'ldapauth')) {
|
||||||
try {
|
try {
|
||||||
LdapStrategy = require('passport-ldapauth').Strategy; // eslint-disable-line global-require
|
LdapStrategy = require('passport-ldapauth').Strategy; // eslint-disable-line global-require
|
||||||
authMode = 'ldapauth';
|
authMode = 'ldapauth';
|
||||||
|
@ -54,7 +55,7 @@ if (config.ldap.enabled) {
|
||||||
|
|
||||||
ldapStrategyOpts = {
|
ldapStrategyOpts = {
|
||||||
server: {
|
server: {
|
||||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port,
|
url: ldapProtocol + '://' + config.ldap.host + ':' + config.ldap.port,
|
||||||
searchBase: config.ldap.baseDN,
|
searchBase: config.ldap.baseDN,
|
||||||
searchFilter: config.ldap.filter,
|
searchFilter: config.ldap.filter,
|
||||||
searchAttributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
searchAttributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue