Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP auth #147

Closed
ionutchirvasa opened this issue Apr 19, 2016 · 2 comments
Closed

LDAP auth #147

ionutchirvasa opened this issue Apr 19, 2016 · 2 comments

Comments

@ionutchirvasa
Copy link

Was anybody able to implement LDAP authentication?

@danieltjewett
Copy link

@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
Copy link
Author

@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).

  • ./api/services/protocols/ldaputh.js - my custom protocol callback function
  • ./api/services/protocols/index.js - add your custom protocol callback to existing protocols that now point to sails-auth protocols directory
  • ./api/services/passport.js - extend with protocols: require('./protocols') to load your new protocol list
  • ./config/passport.js - your ldapauth protocol config

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants