2.0.0 • Published 8 years ago

cti-jwt-dealer-strategy v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

cti-passport-jwt-bearer-strategy

JWT token signer and a Passport strategy for authenticating requests based on CTI bearer tokens and assigning relevant scopes.

Usage

const express = require( 'express' );
const passport = require( 'passport' );

const jwtDealerStrategy = require( 'cti-jwt-dealer-strategy' );

const key = 'key';
const issuer = 'issuer';
const audience = 'audience';

const strategy = jwtDealerStrategy.passportStrategy(
    key,
    { issuer: issuer, audience: audience }
);

passport.use( strategy );

const bearerAuthenticator =
    passport.authenticate( strategy.name, { session: false } );

const app = express();
express.get( '/', bearerAuthenticator, ( req, res ) => {
    res.send( 'You\'ve authenticated!' );
} );
const jwtDealerStrategy = require( 'cti-jwt-dealer-strategy' );

const payload = {
	uid: 'foo',
	dealerId: 'bar'
};
const key = 'key';
const options = {
	issuer: 'issuer',
	audience: 'audience',
	expiresIn: 60
};

const token = jwtDealerStrategy.signToken(
	payload,
    key,
    options
);

console.log( token );
2.0.0

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago