Skip to content

Commit

Permalink
add login audit log for ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Nov 1, 2018
1 parent 24f5679 commit 092b366
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/auth/ldap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
// Doc: https://github.com/vesse/passport-ldapauth#readme
const LdapStrategy = require('passport-ldapauth');

const { auditLogin } = require('../../../audit/actions');
const util = require('../../middleware/util');
const auth = require('../../middleware/auth');

exports.init = function (passport, router, config) {
const strategyConfig = Object.assign({ passReqToCallback: true }, config);
passport.use(
new LdapStrategy(config, function (user, done) {
new LdapStrategy(strategyConfig, function (req, user, done) {
const data = {
provider: 'ldap',
email: user.mail,
Expand All @@ -26,11 +28,13 @@ exports.init = function (passport, router, config) {
return Promise.resolve(config.getUserInfo(user)).then(
(info) => {
data.info = info;
auditLogin(data.email, true, 'ldap', req.ctx);
done(null, data);
},
(err) => done(err)
);
} else {
auditLogin(data.email, true, 'ldap', req.ctx);
done(null, data);
return true;
}
Expand Down

0 comments on commit 092b366

Please sign in to comment.