node-identity

v1.1.0
Security Middleware for identity server

Node Identity

Security Middleware

Installation

  • npm install node-identity

Usage

var identity = require('node-identity');
var request = require('request-json');

var express = require('express');
var app = express();

// Add the security middleware
var identityHost = 'http://localhost:4000';
var identityToken = 'x-bi-joe-auth-token';

app.use(new identity.security(request, identityHost, identityToken));

// Protected routes
app.get('/protected', new identity.authentication(), function(req, res) {
  console.log(req.security.authenticated); // outputs true
  console.log(req.security.token); // outputs the security token
  console.log(req.security.user); // outputs the user object
});

// Authorisation
app.get('/admin', new identity.authorization(['feature-admin']), function(req, res) {
  console.log('route only if the feature "feature-admin" is authorized');
});
npm i node-identity

Metadata

  • MIT
  • Whatever
  • Unknown
  • released 11/24/2014

Downloads

Maintainers