Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

seneca-auth - a Seneca plugin

Seneca Auth Plugin

A user authentication plugin, using PassportJS.

Build Status


For a gentle introduction to Seneca itself, see the 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-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:


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
Something went wrong with that request. Please try again.