cti-jwt-dealer-strategy

2.0.0 • Public • Published

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 );

/cti-jwt-dealer-strategy/

    Package Sidebar

    Install

    npm i cti-jwt-dealer-strategy

    Weekly Downloads

    1

    Version

    2.0.0

    License

    MIT

    Last publish

    Collaborators

    • cantireinnovations