
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
passport-http-header-strategy
Advanced tools
HTTP Bearer set header authentication strategy for Passport
HTTP define header authentication strategy for Passport
$ npm install passport-http-header-strategy
header
set header(default authorization
)param
set use req.body
or req.query
token
name to request(default access_token
)passReqToCallback
if eturnpassport.use(new headerStrategy({header: 'X-APP-TOKEN', param: 'app_token', passReqToCallback: true},
function(req, token, done) {
User.findOne({ token: token }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
return done(null, user, { scope: 'all' });
});
}
));
Use passport.authenticate()
, specifying the 'bearer'
strategy, to
authenticate requests. Requests containing bearer tokens do not require session
support, so the session
option can be set to false
.
For example, as route middleware in an Express application:
app.get('/profile',
passport.authenticate('header', { session: false }),
function(req, res) {
res.json(req.user);
});
examples - example
$ npm install
$ mocha
ReferJared Hanson passport-http-bearer module
FAQs
HTTP Bearer set header authentication strategy for Passport
The npm package passport-http-header-strategy receives a total of 7,023 weekly downloads. As such, passport-http-header-strategy popularity was classified as popular.
We found that passport-http-header-strategy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.