]>
git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blob - src/auth.js
3d2acce1eeb116a7bf3688bf3852e102beaba312
3 var passport
= require('passport'),
4 LdapStrategy
= require('passport-ldapjs').Strategy
;
6 var LDAP_URL
= process
.env
.LDAP_URL
;
7 var LDAP_USERS_BASE_DN
= process
.env
.LDAP_USERS_BASE_DN
;
9 if (LDAP_URL
&& LDAP_USERS_BASE_DN
) {
10 console
.log('Enable ldap auth');
12 exports
.ldap
= passport
.authenticate('ldap', {
13 successReturnToOrRedirect: '/',
14 failureRedirect: '/login',
18 exports
.ldap = function (req
, res
, next
) {
19 console
.log('ldap auth disabled');
28 base: LDAP_USERS_BASE_DN
,
30 filter: '(uid={{username}})',
31 attributes: ['displayname', 'username', 'mail', 'uid'],
35 usernameField: 'username',
36 passwordField: 'password',
39 passport
.use(new LdapStrategy(opts
, function (profile
, done
) {
40 console
.log('ldap', profile
);