瀏覽代碼

fix: handle multiple LDAP strategies (#5116)

Manuel 3 年之前
父節點
當前提交
1f489a3d8e
共有 3 個文件被更改,包括 3 次插入2 次删除
  1. 1 0
      server/core/auth.js
  2. 1 1
      server/models/users.js
  3. 1 1
      server/modules/authentication/ldap/authentication.js

+ 1 - 0
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
 

+ 1 - 1
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) => {

+ 1 - 1
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,