trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
265 stars 141 forks source link

LDAP auth #147

Closed ionutchirvasa closed 8 years ago

ionutchirvasa commented 8 years ago

Was anybody able to implement LDAP authentication?

danieltjewett commented 8 years ago

@ionut72 Were you able to figure this out? If so, could you share? I've been researching this on and off for the last few weeks in my spare time, with no luck. I currently get a Failed to serialize user into session error.

ionutchirvasa commented 8 years ago

@danieltjewett
I was able to implement this feature using vesse/passport-ldapauth and created ./config/passport.js with a new provider( see issue #79 for more details).

The reason why you get that error is because you have no id attribute set to your returned user model. To fix this you have to call sails.services.passport.loadStrategies(); after sails boots in order to correctly load your custom ldapauth protocol(here you map LDAP result to you user schema).

I called loadStrategies in ./config/bootstrap.js like this: sails.on('lifted', function() { sails.services.passport.loadStrategies(); });

To authenticate you have to use this route: /auth/:provider/callback. I've created a new entry to allow POST requests.