1.1.6 • Published 4 years ago

spike-auth-middleware v1.1.6

Weekly downloads
16
License
ISC
Repository
-
Last release
4 years ago

Spike npm module: "spike-auth-middleware"

This REPO is a Spike npm module that can be used to recieve an Authorization Bearer Token express.js middleware to allow certain scopes to certain endpoints.

npm version

NPM


Usage

const path = require("path");
const { getSpikeAuthMiddleWare } = require("spike-auth-middleware");

const configuration = {
    audience: 'audience',
    allowedScopes: ["read"],
    pathToPublicKey: path.resolve(__dirname, 'relative/path/to/certificate')
};

const allowForReadScopeOnly =  getSpikeAuthMiddleWare(configuration);

// express.js code:
app.get('/', allowForReadScopeOnly, (req,res,next) => {
    res.status(200).send('allowed for read scope');
})

Options For getSpikeAuthMiddleWare

  • audience: (String) audience to demand in JWT payload
  • pathToPublicKey: full path to public key to authenticate JWT signature with
  • allowedScopes: (Array) list of all allowed scopes in this middleware - default: "read"
  • useBearerToken: (Boolean) set to true if Authorization header should start with 'Bearer' - default: true
1.1.6

4 years ago

1.1.5

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago