seneca-auth - a Seneca plugin
A user authentication plugin, using PassportJS.
For a gentle introduction to Seneca itself, see the senecajs.org site.
If you're using this plugin module, feel free to contact me on twitter if you have any questions! :) @rjrodger
Current Version: 0.3.0
Tested on: Seneca 0.5.19, Node 0.10.29
npm install seneca-authNOTE: documentation is in progress. Take a look at the user accounts example.
The API endpoints return a HTTP redirect when a form submission is made against them. That is, when the Content-Type header is one of:
- application/x-www-form-urlencoded
- multipart/form-data
For application/json, a JSON response is returned instead of a redirect.
You can control this behavior explicitly by providing a redirect=yes|no query parameter:
/auth/login?redirect=yes
You can also control this behaviour using the plugin options:
seneca.use('auth', {redirect:{always:true}} )
With always:true, a redirect always occurs.
The default behaviour is to redirect if no other rule above applies.
The module takes a restrict parameter (string or array) to allow only authenticated requests to those endpoints. It will return HTTP code 401 (Unauthorized) for requests matching these paths.
seneca.use('auth', {restrict:['/api/']})
Login an existing user and set a login token. A new login entity is created for each login.
- default url path: /auth/login
- options property: urlpath.login
Logout an existing user with an active login. The login entity is updated to reflect the end of the login.
- default url path: /auth/logout
- options property: urlpath.logout
Get the details of an existing, logged in user.
- default url path: /auth/instance
- options property: urlpath.instance

