Obsoleting some old files
Transition to SPA-style client Basis for Mosaico template editor
This commit is contained in:
parent
7750232716
commit
c85f2d4440
942 changed files with 86311 additions and 967 deletions
|
@ -16,20 +16,53 @@ const { nodeifyFunction, nodeifyPromise } = require('./nodeify');
|
|||
const interoperableErrors = require('../shared/interoperable-errors');
|
||||
const contextHelpers = require('./context-helpers');
|
||||
|
||||
let LdapStrategy;
|
||||
let authMode = 'local';
|
||||
|
||||
let LdapStrategy;
|
||||
let ldapStrategyOpts;
|
||||
if (config.ldap.enabled) {
|
||||
if (config.ldap.method == 'ldapjs') {
|
||||
if (!config.ldap.method || config.ldap.method == 'ldapjs') {
|
||||
try {
|
||||
LdapStrategy = require('passport-ldapjs').Strategy; // eslint-disable-line global-require
|
||||
authMode = 'ldapjs';
|
||||
log.info('LDAP', 'Found module "passport-ldapjs". It will be used for LDAP auth.');
|
||||
|
||||
ldapStrategyOpts = {
|
||||
server: {
|
||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port
|
||||
},
|
||||
base: config.ldap.baseDN,
|
||||
search: {
|
||||
filter: config.ldap.filter,
|
||||
attributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
||||
scope: 'sub'
|
||||
},
|
||||
uidTag: config.ldap.uidTag,
|
||||
bindUser: config.ldap.bindUser,
|
||||
bindPassword: config.ldap.bindPassword
|
||||
};
|
||||
|
||||
} catch (exc) {
|
||||
log.info('LDAP', 'Module "passport-ldapjs" not installed. It will not be used for LDAP auth.');
|
||||
}
|
||||
} else if (config.ldap.method == 'ldapauth') {
|
||||
}
|
||||
|
||||
if (!LdapStrategy && (!config.ldap.method || config.ldap.method == 'ldapauth')) {
|
||||
try {
|
||||
LdapStrategy = require('passport-ldapauth').Strategy; // eslint-disable-line global-require
|
||||
authMode = 'ldapauth';
|
||||
log.info('LDAP', 'Found module "passport-ldapauth". It will be used for LDAP auth.');
|
||||
|
||||
ldapStrategyOpts = {
|
||||
server: {
|
||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port,
|
||||
searchBase: config.ldap.baseDN,
|
||||
searchFilter: config.ldap.filter,
|
||||
searchAttributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
||||
bindDN: config.ldap.bindUser,
|
||||
bindCredentials: config.ldap.bindPassword
|
||||
},
|
||||
};
|
||||
} catch (exc) {
|
||||
log.info('LDAP', 'Module "passport-ldapauth" not installed. It will not be used for LDAP auth.');
|
||||
}
|
||||
|
@ -123,42 +156,12 @@ module.exports.restLogin = (req, res, next) => {
|
|||
})(req, res, next);
|
||||
};
|
||||
|
||||
if (authMode === 'ldapjs' || authMode === 'ldapauth') {
|
||||
if (LdapStrategy) {
|
||||
log.info('Using LDAP auth (passport-' + authMode + ')');
|
||||
module.exports.authMethod = 'ldap';
|
||||
module.exports.isAuthMethodLocal = false;
|
||||
|
||||
let opts;
|
||||
if (authMode === 'ldapjs') {
|
||||
opts = {
|
||||
server: {
|
||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port
|
||||
},
|
||||
base: config.ldap.baseDN,
|
||||
search: {
|
||||
filter: config.ldap.filter,
|
||||
attributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
||||
scope: 'sub'
|
||||
},
|
||||
uidTag: config.ldap.uidTag,
|
||||
bindUser: config.ldap.bindUser,
|
||||
bindPassword: config.ldap.bindPassword
|
||||
};
|
||||
|
||||
} else if (authMode = 'ldapauth') {
|
||||
opts = {
|
||||
server: {
|
||||
url: 'ldap://' + config.ldap.host + ':' + config.ldap.port,
|
||||
searchBase: config.ldap.baseDN,
|
||||
searchFilter: config.ldap.filter,
|
||||
searchAttributes: [config.ldap.uidTag, config.ldap.nameTag, 'mail'],
|
||||
bindDN: config.ldap.bindUser,
|
||||
bindCredentials: config.ldap.bindPassword
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
passport.use(new LdapStrategy(opts, nodeifyFunction(async (profile) => {
|
||||
passport.use(new LdapStrategy(ldapStrategyOpts, nodeifyFunction(async (profile) => {
|
||||
try {
|
||||
const user = await users.getByUsername(profile[config.ldap.uidTag]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue