Skip to content

SpringRole/passport-yoti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-yoti

Passport strategy for authenticating with Yoti

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

Install

$ npm install passport-yoti

Usage

Configure Strategy

The Civic authentication strategy authenticates users using a Civic app. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a appId, prvKey, and appSecret.

passport.use(new YotiStrategy({
    clientSdkId: 'your sdk id',
    prvKey: fs.readFileSync(/keys/your-application-pem-file.pem)
  },
  function(profile, done) {
    User.findOrCreate({ userId: profile.userId }, function (err, user) {
      return done(err, user);
    });
  }
));

Parameters

The verify callback can be supplied with the request object by setting the passReqToCallback option to true, and changing callback arguments accordingly.

passport.use(new YotiStrategy({
    clientSdkId: 'your sdk id',
    prvKey: fs.readFileSync(/keys/your-application-pem-file.pem)
    passReqToCallback: true
  },
  function(req, profile, done) {
    // request object is now first argument
    // ...
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Credits

License

The MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published