1.0.1 • Published 11 months ago

@easyauth.io/passport-easyauth v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Passport-EasyAuth

The EasyAuth authentication strategy for Passport.js, an authentication middleware for Node.js that can be unobtrusively dropped into any Express-based web application.

Getting started

Installation

The EasyAuth Passport strategy is installed with npm.

npm install @easyauth.io/passport-easyauth

Create Strategy

//Strategy.js

const passport = require('passport');
const EasyAuthStrategy = require('passport-easyauth');

passport.use(
  new EasyAuthStrategy(
    {
      discoveryURL: '',
      clientID: '',
      clientSecret: '',
      callbackURL: [''],
    },
    function (tokenset, userinfo, done) {
      done(null, userinfo);
    }
  )
);

Set:

discoveryURL to EasyAuth Tenant URL.

clientID to Registered Client ID of respective EasyAuth Tenant.

clientSecret to Client secret of respective ClientID.

callbackURL to Redirect URL of respective ClientID.

Express Usage

//index.js

app.get(
  "loginURL",
  passport.authenticate("easyauth", { scope: "openid" })
);

app.get(
  "callbackURL",
  passport.authenticate("easyauth", { failureRedirect: "loginURL" }),
  
  //Authentication successful
  (req, res) => {
    res.redirect("protectedURL");
  }
);
1.0.1

11 months ago

1.0.0

11 months ago