Giter VIP home page Giter VIP logo

passport-oauth2-jwt-bearer's Introduction

passport-oauth2-jwt-bearer

JSON Web Token (JWT) Bearer Token Profiles for OAuth 2.0 client authentication strategy for Passport.

This module lets you authenticate requests containing client credentials in a JWT sent in the request body's assertion field, as defined by the JSON Web Token (JWT) Bearer Token Profiles for OAuth 2.0 draft. These credentials are typically used to protect the token endpoint and used as an alternative to HTTP Basic authentication. This module is modeled off of Google's OAuth 2.0 Server to Server Applications. This module can be used with the oauth2orize-jwt-bearer module to create a JWT OAuth 2.0 exchange scenario server.

Install

$ npm install passport-oauth2-jwt-bearer

Usage

Configure Strategy

The JSON Web Token (JWT) Bearer Token Profiles for OAuth 2.0 client authentication strategy authenticates clients using a JWT. The strategy requires a verify callback, which accepts those credentials and calls done providing a client.

var ClientJWTBearerStrategy = require('passport-oauth2-jwt-bearer').Strategy;

passport.use(new ClientJWTBearerStrategy(
  function(claimSetIss, done) {
    Clients.findOne({ clientId: claimSetIss }, function (err, client) {
      if (err) { return done(err); }
      if (!client) { return done(null, false); }
      return done(null, client);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'oauth2-jwt-bearer' strategy, to authenticate requests.

For example, as route middleware in an Express application, using OAuth2orize middleware to implement the token endpoint:

app.get('/profile',
  passport.authenticate(['oauth2-jwt-bearer'], { session: false }),
  oauth2orize.token());

Tests

$ npm install --dev
$ make test

Credits

License

The MIT License

Copyright (c) 2012-2013 xTuple <http://www.xtuple.com/>

passport-oauth2-jwt-bearer's People

Contributors

bendiy avatar shackbarth avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.