Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sequelize-authentication

sequelize18MIT0.3.0

A connect module for authentication against a database.

readme

sequelize-authentication

A connect module for authentication against a database.

Usage:

var app            = express()
  , authentication = require('sequelize-authentication')
  , Sequelize      = require('sequelize')
  , sequelize      = new Sequelize('database', 'user', 'password')

app.configure(function() {
  app.use(authentication(sequelize[, options]))
})

Note: If you are serving static files (e.g. via express.static), make sure, that authentication is added afterwards.

Options

The second parameter of the authentication function is an object with options.

via

You can define, where the module will find the credentials.

Credentials in the URL

authentication(sequelize, { via: 'query' })
curl "http://localhost?user=username&password=password"

Credentials in the post body

authentication(sequelize, { via: 'body' })
curl -d "user=username&password=password" http://localhost

Credentials in the params

authentication(sequelize, { via: 'params' })
# works for params in the query
curl "http://localhost?user=username&password=password"

# and for params in the post body
curl -d "user=username&password=password" http://localhost

Credentials in the headers

authentication(sequelize, { via: 'headers' })
curl -d "user=username&password=password" http://localhost

Hm? So, what's next?

Each request to your server will check

changelog

Changelog

v0.3.0

  • added possibility to define the parameter, in which the credentials are scoped

v0.2.0

  • added authentication via headers
  • added authentication via query and/or post body
  • added scoping of authentication

v0.1.0

  • added authentication via credentials in the URL or in the post body