express-authorization-bearer
v1.0.2
Published
Bearer authorization token middleware for express.
Downloads
26
Maintainers
Readme
About
Bearer authorization token middleware for express.
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