Skip to content

alirezabonab/passport-tosan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-tosan

Passport strategy for authenticating with Tosan using the OAuth 2.0 API.

This module lets you authenticate using Tosan in your Node.js applications. By plugging into Passport, Tosan authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-tosan

Usage

Configure Strategy

The Tosan authentication strategy authenticates users using a Tosan Core Banking account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying an app ID, app secret, callback URL.

module.exports = new BoomrangStrategy({
        clientID: 'boom_app_key',
        scope: '',
        bankId: default is 'ANSBIR',
        boomToken: token_you_got_from_boom_login,
        deviceId: 'device_id',
        clientSecret: 'boom_app_secret_key',
        callbackURL: 'http://localhost:3000/auth/tosan/callback'
    },
    function (accessToken, profile, done) {
       // profile contains user profile also below items
       //    access-token, 
       //    refresh-token( If you have access to get refresh token ), 
       //    scopes, 
       //    tokenExpiresIn ( Token Expire Time )
    }
);

Authenticate Requests

Use 'passport.authenticate()', specifying the 'tosan' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/tosan',
  passport.authenticate('tosan'));

app.get('/auth/tosan/callback',
  passport.authenticate('tosan', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

It is possible to set bankId from url query--strings :

http://localhost:3000/auth/tosan?bank_id=CIYBIR

Examples

For a complete, working example, refer to the login example.

Tests

$ npm install
$ npm test

Credits

License

The MIT License

Copyright (c) 2015 Alireza Alidoust

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published