Fer*_*ani 7 ssl ldap node.js passport.js
我正在尝试使用passport-ldapauth和express对LDAP服务器进行身份验证.
使用ldap url(ldap:// myserver ...)的身份验证工作正常,但是使用ldaps我得到:
TypeError: Cannot read property 'on' of undefined
at setupSocket (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:111:14)
at Client._connect (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:742:3)
at new Client (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:247:22)
at Object.createClient (...\ldapauth-fork\node_modules\ldapjs\lib\client\index.js:60:12)
at new LdapAuth (...\ldapauth-fork\lib\ldapauth.js:129:28)
at handleAuthentication (...\passport-ldapauth\lib\passport-ldapauth\strategy.js:140:10)
at Strategy.authenticate (...\passport-ldapauth\lib\passport-ldapauth\strategy.js:175:33)
at attempt (...\passport\lib\middleware\authenticate.js:341:16)
at authenticate (...\passport\lib\middleware\authenticate.js:342:7)
at Layer.handle [as handle_request] (...\express\lib\router\layer.js:82:5)
我的代码基本上是这样的:
...
passport.use(new LdapStrategy({
server: {
url: 'ldaps://myserver:636',
searchBase: '...',
searchFilter: '(uid={{username}})',
tlsOptions: {
ca: [
fs.readFileSync('myCAcert.pem')
]
}
},
session: false,
usernameField:'u',
passwordField:'p'
},
function(user, done) {
console.log("Interna: \nOK");
console.log("u:");
console.log(user.cn);
return done(null, user);
}));
app.use('/login',passport.authenticate('ldapauth',
{ session:false,
successRedirect:'/accessed',
failureRedirect: '/accessfail'
}
));
app.use('/accessed',function (req,res,next){
res.send("User OK");
});
app.use('/accessfail',function (req,res,next){
res.send("User MAL !!!!!!!");
});
app.listen(3336);
Run Code Online (Sandbox Code Playgroud)
我的库版本是:
express@4.11.2, passport@0.2.1,passport-ldapauth@0.3.0
有人可以帮帮我吗?
谢谢.
最后,我可以解决这个问题.
ldapauth-fork中使用的ldapjs版本不能与ldaps url一起使用.
解决方案是:
从ldapauth-fork中的ldapauth-fork中删除ldapjs,在ldapauth-fork下的node_modules目录下(在我的用户!!!!!!的node_modules中的passport-ldap下的其他node_modules目录下),执行以下命令:
npm rm ldapjs
使用以下命令从github安装新版本:
npm install git://github.com/mcavage/node-ldapjs.git
FDO.
| 归档时间: |
|
| 查看次数: |
1920 次 |
| 最近记录: |