<commit_before># Passport-HTTP-Bearer

HTTP Bearer authentication strategy for [Passport](https://github.com/jaredhanson/passport).

## Credits

  - [<NAME>](http://github.com/jaredhanson)

## License

(The MIT License)

Copyright (c) 2011 <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy of<commit_msg>Update README.<commit_after># Passport-HTTP-Bearer

HTTP Bearer authentication strategy for [Passport](https://github.com/jaredhanson/passport).

## Installation

    $ npm install passport-http-bearer

## Usage

#### Configure Strategy

The HTTP Bearer authentication strategy authenticates users using a bearer
token.  The strategy requires a `validate` callback, which accepts that
credential and calls `done` providing a user.

    passport.use(new BearerStrategy(
      function(token, done) {
        User.findOne({ token: token }, function (err, user) {
          if (err) { return done(err); }
          if (!user) { return done(null, false); }
          if (!sufficientScope(user, token)) { return done(new bearer.AuthenticationError('', 'insufficient_scope')); }
          return done(null, user);
        });
      }
    ));

#### 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](http://expressjs.com/)
application:

    app.get('/profile', 
      passport.authenticate('bearer', { session: false }),
      function(req, res) {
        res.json(req.user);
      });

#### Examples

For a complete, working example, refer to the [Bearer example](https://github.com/jaredhanson/passport-http-bearer/tree/master/examples/bearer).

## Implementation

This module is implemented based on [The OAuth 2.0 Authorization Protocol: Bearer Tokens](http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-12),
Draft 12.  Implementers are encouraged to track the progress of this
specification and update update their implementations as necessary.
Furthermore, the implications of relying on a non-final draft specification
should be understood prior to deployment.

## Credits

  - [<NAME>](http://github.com/jaredhanson)

## License

(The MIT License)

Copyright (c) 2011 <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy of
{'fraction_non_alphanumeric': 0.11289658014009064, 'fraction_numerical': 0.006180469715698393, 'mean_word_length': 4.047817047817047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3120445', 'n_tokens_mistral': 724, 'n_tokens_neox': 681, 'n_words': 232}