@oddnetworks/express-auth-request

Middleware for decoding access and authorization tokens

Usage no npm install needed!

<script type="module">
  import oddnetworksExpressAuthRequest from 'https://cdn.skypack.dev/@oddnetworks/express-auth-request';
</script>

README

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}));