1.0.0 • Published 8 years ago

@oddnetworks/express-auth-request v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

express-auth-request

Middleware for authorizing requests to Odd resources.

Install (WIP)

npm install @oddnetworks/express-auth-request

Usage

This middleware exposed 2 separate methods to to handle the X-Access-Token and the Authorization headers and makes Seneca calls to the right resources to validate and decorate the requests accordingly.

const config = require('./config');
const seneca = require('seneca')();
const express = require('express');

const authRequest = require('express-auth-request');

// Protect all resources with x-access-token
app.use(authRequest.accessToken({secret: config.JWTSecret, seneca: seneca}));

// Protect certain routes based on entityId with user specific Authorization
app.get('/videos/:entityId', authRequest.authorizationToken({secret: config.JWTSecret, seneca: seneca}));