I have setup feathersjs with ldap authentication, which requires feathers-authentication version 1. It works fine over rest using app.authenticate but it fails when using sockets. After enabling debugging, I confirmed that the server gets the credentials and successfully generates the token. The client, however, is not able to get the response. The server is emitting 'authentication created' which the client gets only when using socket.on('authentication created')
not when using app.authenticate()
. I know I can use plain socket and get the job done but the docs recommend using app.authenticate
and then use app.service('someService')
.
The following snippet works fine with rest but not with socket.
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);
});
This is how I setup sockets:
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 }));