2max-express-authenticate
Simply authentication for express based on Sequelize.
Last updated 2 years ago by 2max .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install 2max-express-authenticate 
SYNC missed versions from official npm registry.

Express authenticate

Simply authentication for express based on Sequelize.

Install

npm i 2max-express-authenticate --save

Configuration

const express = require('express');
const app = express();
const auth = require('2max-express-authenticate');

async function main(app) {
  // Declare auth + configure for persistence
  const util = await auth(app, {
    'persistence': {
      'host': process.env.MYSQL_HOST,
      'user': process.env.MYSQL_USER,
      'password': process.env.MYSQL_PASSWORD,
      'database': process.env.MYSQL_DATABASE,
      'dialect': 'mysql'
    }
  });

  // Secure yours routes with auth
  util.secure([
    '/admin',
    '/dashboard',
    ...
  ]);

  // Override connection method for send custom results
  util.override({
    'login': (req, res) => {
      res.send('Congrats');
     },
     'logout': (req, res) => {
       res.send('OUT');
     },
     'signup': (req, res) => {
       res.send('Good job mother fucker men');
     }
  });
}

app.listen(80);

Route

Method endpoint Body
POST /signup {username, password}
POST /login {username, password}
GET /logout N/A

Features

  • Crypt password with bcrypt
  • Login, logout and signup (cookies + session)
  • Persist data (according to sequelize compatibility)
  • Give array with route to check session for each route
  • Enable middlewares for set response from /login, /logout and /signup

Todo

  • Add roles checking (bitmask)
  • Secure route according to roles
  • User can add role

Current Tags

  • 0.0.122                                ...           latest (2 years ago)

5 Versions

  • 0.0.122                                ...           2 years ago
  • 0.0.121                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 5
This Month 26
Last Day 0
Last Week 7
Last Month 11
Dependencies (8)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |