0.0.10 • Published 5 years ago

express-devise-token-auth v0.0.10

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

Express Devise Token Auth (WARNING: Not production ready yet!)

Information

Express Devise Token Auth is a general middleware that adds the ability to express projects authenticate users through a devise-token-auth micro service running with Rails.

Basically this middleware validates token information and acts like a before_action :authenticate_user that we have in Rails.

Installation

npm install express-devise-token-auth --save

Setup

The setup is pretty straight forward and easy, you just need to:

Protecting all routes

const app = require('express')();
const authentication = require('express-devise-token-auth');

const customAuth = {
  deviseURL: 'http://localhost:3000',
  deviseScope: 'v1',
  deviseFor: 'indicator',
};

app.use(authentication(customAuth))

app.get('/', (req, res) => {
  res.send(req.user);
});

app.listen(8080);

module.exports = app;

Protecting just some routes

const app = require('express')();
const authentication = require('express-devise-token-auth');

const adminRoutes = require('../routes');

const customAuth = {
  deviseURL: 'http://localhost:3000',
  deviseScope: 'v1',
  deviseFor: 'indicator',
};

app.get('/admin', authentication(customAuth), adminRoutes);

app.listen(8080);

module.exports = app;
0.0.10

5 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago