# passport-http-header-token

> Passport strategy for authenticating with a http header token

Latest version **1.1.0** (published 2016-06-17) · 0 weekly downloads

## Install

```sh
npm install passport-http-header-token
pnpm add passport-http-header-token
yarn add passport-http-header-token
bun add passport-http-header-token
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-06-17 |
| First published | 2014-10-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Pelle Almquist |
| Maintainers | peralmq |
| Keywords | passport, auth, authn, authentication, header, token |

## Links

- npm: https://www.npmjs.com/package/passport-http-header-token
- Repository: https://github.com/peralmq/passport-http-header-token
- Homepage: https://github.com/peralmq/passport-http-header-token#readme
- Issues: http://github.com/peralmq/passport-http-header-token/issues
- npm.io page: https://npm.io/package/passport-http-header-token

## Dependencies (1)

- [passport-strategy](https://npm.io/package/passport-strategy.md) 1.x.x

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-06-17
- 1.0.0 — 2014-10-28

## README

# passport-http-header-token
[Passport](http://passportjs.org/) strategy for authenticating with a http header token - based on [passport-local](https://github.com/jaredhanson/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](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).

## Install

    $ npm install passport-http-header-token

## Usage

#### 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](http://expressjs.com/)
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](https://github.com/peralmq/passport-http-header-token/tree/master/examples/http-header-token).

## Tests

    $ npm install
    $ npm test

## Credits

  - [Jared Hanson](http://github.com/jaredhanson)

## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2011-2014 Pelle Almquist

---
_Source: https://npm.io/package/passport-http-header-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
