egg-passport-ldap

1.0.0 • Public • Published

用法

config/config.default.js

  // passportLdap 配置参考: https://github.com/vesse/passport-ldapauth
  
  module.exports = appInfo => {
    const config = {};
    config.passportLdap = {
        server: {
          url: 'ldap://localhost:389',
          bindDN: 'cn=admin,ou=users,dc=exmaple,dc=com',
          bindCredentials: 'Test123',
          searchBase: 'dc=example,dc=com',
        },
        usernameField: 'name',
        passwordField: 'pass',
        passReqToCallback: true
      };
  }

config/plugin.js

exports.passportLdap = {
  enable: true,
  package: 'egg-passport-ldap',
};

app.js

 app.passport.verify(async (ctx, user) => {
    ctx.logger.debug('passport.verify', user);
    return user;
  });

router.js

const ldapStrategy = app.passport.authenticate('ldapauth');
router.post('/passport/ldap', ldapStrategy);

Package Sidebar

Install

npm i egg-passport-ldap

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.96 kB

Total Files

5

Last publish

Collaborators

  • gaoletian