passport-raindrop

1.0.3 • Public • Published

Raindrop Passport Module

The 'raindrop' strategy authenticates a user by confirming the user has input an API-generated message into the Hydro mobile app.

Installation

$ npm install passport-raindrop

Configuration

The verify callback is required to verify a valid site user is being authenticated. Authentication fails if no user is found.

const passport = require('passport'),
      RaindropStrategy = require('passport-raindrop')      

// Initialize the raindrop. Declared as a variable in order to access Raindrop SDK functions later.   
let raindrop = new RaindropStrategy({
    environment: ENVIRONMENT,
    clientId: CLIENT_ID,
    clientSecret: CLIENT_SECRET,
    applicationId: APPLICATION_ID
}, function (authUser, done) {   
    // This verifies the user and returns it to the authentication
    let user = userDB.find(usr => usr.hydroId === authUser.hydroId);
    return user ? done(null, user) : done(new Error('User not found.'), null);
});

// Pass the strategy into passport
passport.use(raindrop);

Usage

Authenticate Requests

Use passport.authenticate() and specify the 'raindrop' strategy.

passport.authenticate('raindrop', {
    successRedirect: '/pass',
    failureRedirect: '/fail'
})(req, res, next);

Generate Verification Message

let message = HydrogenAPI.raindrop.generateMessage();

In this example HydrogenAPI is the export from the above 'Configuration'. See the 'Complete Example' below for the full in-context configuration.

Complete Example

A complete example of using this library.

Documentation

Hydrogen API

Passport JS

Author

Red-Maximus

License

Unlicensed

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    0
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i passport-raindrop

Weekly Downloads

0

Version

1.0.3

License

none

Unpacked Size

4.3 kB

Total Files

4

Last publish

Collaborators

  • red-maximus