Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to authenticate Sails JS application using Passport? [duplicate]

I am using Sails v0.10.5. I want to integrate an authentication system with username and password using Passport. For that I was going through the following documentations:

  • [How To] Implement Passport.js Authentication with Sails.js
  • CREATING A SAILS APPLICATION USING PASSPORT AUTHENTICATION

But, I have seen in the comments that these are outdated and no longer works with sails v0.10.5. I tried these, it was not authenticating and I was able to access all the controller actions without any authentication.

Is there any updated version or any other useful documentation for integrating?

like image 423
Yedhu Krishnan Avatar asked Nov 26 '14 11:11

Yedhu Krishnan


2 Answers

I strongly advise you to try sails-generate-auth generator. It is based on passport and it creates whole authentication layer for your sails.js application including local policy (user/password), OAuth2.0 and OpenID.

Sails-generate-auth will create for you two new models (User, Passport), authentication controller, service, configure routes and policies. So if you want to apply authentication to your existing application it would be safer to create fresh sails application, generate authentication layer using sails-generate-auth, test it a little bit and then copy necessary files to your original application.

Hope that helps.

Edit

sails-auth is also a good solution. Similarily to sails-generate-auth, it generates all necessary models and services so you can connect it easily to your existing service.

like image 119
abeja Avatar answered Nov 12 '22 10:11

abeja


Check out this easy to use example for sails.js with passport.js supporting both Email, Twitter and Facebook: https://github.com/bmustata/sails-auth-super-template

like image 22
bmustata Avatar answered Nov 12 '22 11:11

bmustata