mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
7 years ago
|
/* global wiki */
|
||
|
|
||
|
// ------------------------------------
|
||
|
// LDAP Account
|
||
|
// ------------------------------------
|
||
|
|
||
|
const LdapStrategy = require('passport-ldapauth').Strategy
|
||
7 years ago
|
const fs = require('fs')
|
||
7 years ago
|
|
||
7 years ago
|
module.exports = {
|
||
|
key: 'ldap',
|
||
|
title: 'LDAP / Active Directory',
|
||
7 years ago
|
useForm: true,
|
||
7 years ago
|
props: ['url', 'bindDn', 'bindCredentials', 'searchBase', 'searchFilter', 'tlsEnabled', 'tlsCertPath'],
|
||
|
init (passport, conf) {
|
||
|
passport.use('ldapauth',
|
||
|
new LdapStrategy({
|
||
|
server: {
|
||
|
url: conf.url,
|
||
|
bindDn: conf.bindDn,
|
||
|
bindCredentials: conf.bindCredentials,
|
||
|
searchBase: conf.searchBase,
|
||
|
searchFilter: conf.searchFilter,
|
||
|
searchAttributes: ['displayName', 'name', 'cn', 'mail'],
|
||
|
tlsOptions: (conf.tlsEnabled) ? {
|
||
|
ca: [
|
||
|
fs.readFileSync(conf.tlsCertPath)
|
||
|
]
|
||
|
} : {}
|
||
|
},
|
||
|
usernameField: 'email',
|
||
|
passReqToCallback: false
|
||
|
}, (profile, cb) => {
|
||
|
profile.provider = 'ldap'
|
||
|
profile.id = profile.dn
|
||
|
wiki.db.User.processProfile(profile).then((user) => {
|
||
|
return cb(null, user) || true
|
||
|
}).catch((err) => {
|
||
|
return cb(err, null) || true
|
||
|
})
|
||
|
}
|
||
|
))
|
||
|
}
|
||
7 years ago
|
}
|