Package Exports
- passport-http-header-strategy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (passport-http-header-strategy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
passport-http-header-strategy
HTTP define header authentication strategy for Passport
Install
$ npm install passport-http-header-strategyUsage
headerset header(defaultauthorization)paramset usereq.bodyorreq.querytokenname to request(defaultaccess_token)passReqToCallbackif eturn
Configure Strategy
passport.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' });
});
}
));Authenticate Requests
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
examples - example
Tests
$ npm install
$ mochaReference
ReferJared Hanson passport-http-bearer module