Skip to content

edappy/seneca-auth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

139 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seneca-auth - a Seneca plugin

Seneca Auth Plugin

A user authentication plugin, using PassportJS.

Build Status

Gitter chat

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

Install

npm install seneca-auth

JSON API and Redirects

NOTE: 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

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

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

instance

Get the details of an existing, logged in user.

  • default url path: /auth/instance
  • options property: urlpath.instance

About

seneca-auth

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 92.8%
  • HTML 7.2%