0.1.5 • Published 5 years ago

@tribeca/auth-middleware v0.1.5

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

auth-middleware

Actions Status CodeFactor codecov Dependabot Status

Express auth middleware for tribeca auth service.

This middleware verifies JWT tokens against the tribeca auth service. It returns 401 Unauthorized Http Response if the token is not set in the http header (Authorization: Bearer TOKEN), expired or invalid, and set in req.user the decoded JWT when valid.

Installation

$ npm install @tribeca/auth-middleware --save

Example

const express = require("express");
const authMiddleware = require("@tribeca/auth-middleware");

const app = express();

app.get("/", authMiddleware(), function handleRequest(req, res) {
    // If token is valid it set decoded jwt in req.user
    res.json(req.user);
});

const port = process.PORT || 3000;
app.listen(port, function() {
    console.log(`Server listening at port ${port}`);
})

License

Licensed under MIT.

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

6 years ago

0.0.3

6 years ago