xtuple/passport-oauth2-jwt-bearer

Name: passport-oauth2-jwt-bearer

Owner: xTuple

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

Created: 2013-03-21 20:53:59.0

Updated: 2017-12-26 09:44:29.0

Pushed: 2017-11-07 13:44:31.0

Homepage: null

Size: 15

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits
Jared Hanson2013-09-13 03:16:30.03
bendiy2017-10-13 15:23:58.09
Gil Moskowitz2017-11-07 13:44:30.01
Steve Hackbarth2013-05-22 17:44:11.04
Danny Feliz2017-10-23 15:57:42.01

Other Committers

UserEmailMost Recent Commit# Commits
John Rogelstadjohn@xtuple.com2013-03-21 22:36:04.01

README

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
m 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.

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

port.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:

get('/profile',
passport.authenticate(['oauth2-jwt-bearer'], { session: false }),
oauth2orize.token());
Tests
m install --dev
ke test
Credits
License

The MIT License

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.