express-authorization-bearer

1.0.2 • Public • Published

About

Bearer authorization token middleware for express.

NPM

Purpose?

This module will attempt to extract a bearer token from a request from this location:

  • The value from the header Authorization: Bearer <token>.

If a token is found, it will be stored on req.token. Otherwise, it will abort the request immediately by sending code 401.

const express = require('express');
const bearerAuthorization = require('express-authorization-bearer');
const app = express();
const router = express.Router();
 
router.get('/user/:id', bearerAuthorization, function (req, res) {
    res.send(`token ${req.token}`);
})
 
app.use('/', router);
app.listen(3000);

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Package Sidebar

Install

npm i express-authorization-bearer

Weekly Downloads

6

Version

1.0.2

License

MIT

Last publish

Collaborators

  • onildoaguiar