Package Exports
- passport-http-header-token
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-token) 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-token
Passport strategy for authenticating with a http header token - based on passport-local.
This module lets you authenticate using a username and password in your Node.js applications. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-http-header-tokenUsage
Configure Strategy
The http header token authentication strategy authenticates users using a token.
The strategy requires a verify callback, which accepts the
credential and calls done providing a user.
passport.use(new HTTPHeaderTokenStrategy(
function(token, done) {
User.findOne({ token: token }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
return done(null, user);
});
}
));Authenticate Requests
Use passport.authenticate(), specifying the 'http-header-token' strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.post('/login',
passport.authenticate('http-header-token', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});Examples
For a complete, working example, refer to the HTTP Header Token example.
Tests
$ npm install
$ npm testCredits
License
Copyright (c) 2011-2014 Pelle Almquist