From 1f489a3d8e9c8a015d59e764344b6780708b2cf6 Mon Sep 17 00:00:00 2001 From: Manuel <82898814+frantic91@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:11:24 +0100 Subject: [PATCH] fix: handle multiple LDAP strategies (#5116) --- server/core/auth.js | 1 + server/models/users.js | 2 +- server/modules/authentication/ldap/authentication.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/core/auth.js b/server/core/auth.js index 56f32b3e..38f0b3b8 100644 --- a/server/core/auth.js +++ b/server/core/auth.js @@ -82,6 +82,7 @@ module.exports = { const strategy = require(`../modules/authentication/${stg.strategyKey}/authentication.js`) stg.config.callbackURL = `${WIKI.config.host}/login/${stg.key}/callback` + stg.config.key = stg.key; strategy.init(passport, stg.config) strategy.config = stg.config diff --git a/server/models/users.js b/server/models/users.js index 20da5be7..facb158a 100644 --- a/server/models/users.js +++ b/server/models/users.js @@ -308,7 +308,7 @@ module.exports = class User extends Model { // Authenticate return new Promise((resolve, reject) => { - WIKI.auth.passport.authenticate(selStrategy.strategyKey, { + WIKI.auth.passport.authenticate(selStrategy.key, { session: !strInfo.useForm, scope: strInfo.scopes ? strInfo.scopes : null }, async (err, user, info) => { diff --git a/server/modules/authentication/ldap/authentication.js b/server/modules/authentication/ldap/authentication.js index d1bff88e..8f5a9817 100644 --- a/server/modules/authentication/ldap/authentication.js +++ b/server/modules/authentication/ldap/authentication.js @@ -10,7 +10,7 @@ const _ = require('lodash') module.exports = { init (passport, conf) { - passport.use('ldap', + passport.use(conf.key, new LdapStrategy({ server: { url: conf.url,