我已经使用ldap身份验证设置了feathersjs,这需要使用羽毛身份验证版本1.它使用app.authenticate在休息时工作正常,但在使用套接字时失败。启用调试后,我确认服务器获取凭据并成功生成令牌。但是,客户端无法获得响应。服务器正在发出“已创建身份验证”,客户端仅在使用socket.on('authentication created')
时才会使用app.authenticate()
。我知道我可以使用普通套接字完成工作,但文档建议使用app.authenticate
然后使用app.service('someService')
。
以下代码段可以正常休息,但不适用于套接字。
app.authenticate({
type: 'local',
endpoint: '/authentication',
strategy: 'ldap',
'username': 'user',
'password': 'password'
}).then(function(result){
console.log('Authenticated!', app.get('token'));
}).catch(function(error){
console.error('Error authenticating!', error);
});
这就是我设置套接字的方法:
var socket = io(apiDomain, {
transport: ['websockets']
});
// Set up Feathers client side
var app = feathers()
.configure(feathers.socketio(socket))
.configure(feathers.hooks())
.configure(feathers.authentication({ storage: window.localStorage }));
答案 0 :(得分:2)
feathers-authentication
版本1.x仅适用于feathers-client v2.0.0-pre.1
或更高版本。这仍然是一个预发行版,必须相应地安装(npm install feathers-client@pre --save
)或使用模块加载器加载单个模块feathers-authentication-client。