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
266 stars 141 forks source link

How do I use local auth? #83

Open slavafomin opened 9 years ago

slavafomin commented 9 years ago

Hello!

I'm trying to use sails-auth in one of my projects and I want to use only local strategy. I've tried to figure it out manually, but failed to do so without any proper documentation.

I have the following questions:

  1. What do I need to disable in order to have only local strategy? I don't want to leave any loopholes.
  2. How do I sign user in? I've tried to send POST requests to the /auth/local route, but I can't figure out the correct parameters. I also want to return JSON document with user credentials on success.
  3. How does my policies.js should look?

This module really needs some overall description at least. It's hard to figure out how all this components are working together.

Thank you!

ryanwilliamquinn commented 9 years ago

There is more information in the wiki than on the readme. Here are some answers, anyway:

  1. You don't have to do anything if you are only using local strategy. None of the other strategies are preconfigured.
  2. See here for logging in: https://github.com/tjwebb/sails-auth/wiki/Logging-In
  3. The readme has basic policies.js setup information:
  '*': [ 'basicAuth', 'passport', 'sessionAuth' ],

  AuthController: {
    '*': [ 'passport' ]
  }

The policies above secure everything by default, including registration. In case you wish to open it, add the following:

  UserController: {
    'create': true
  }