Passport strategy for authenticating with OpenPass using OpenID Connect.
$ npm install @openpass/passport-openpass
The OpenPass strategy authenticates users using their OpenPass account. Before your application can make use of OpenPass's authentication system, you must first register your app with OpenPass. Once registered, a client ID and secret will be issued which are used by OpenPass to identify your app.
The OpenPass authentication strategy authenticates users using OpenPass. The strategy requires a verify callback, which accepts these credentials and calls done providing a user profileuser, as well as options specifying a client ID, client secret, and callback URL.
var OpenPassStrategy = require('passport-openpass');
passport.use(new OpenPassStrategy({
clientID: process.env['OPENPASS_CLIENT_ID'],
clientSecret: process.env['OPENPASS_CLIENT_SECRET'],
callbackURL: 'https://www.example.com/oauth2/redirect/openpass'
},
function verify(iss, profile, context, idToken, accessToken, refreshToken, done) {
console.log(profile.id);
//
});
}
));
Two routes are needed in order to allow users to log in with their OpenPass account. The first route redirects the user to the OpenPass, where they will authenticate:
app.get('/login/openpass', passport.authenticate('openpass'));
The second route processes the authentication response and logs the user in, after OpenPass redirects the user back to the app:
app.get('/callback',
passport.authenticate('openpass', { failureRedirect: '/login', failureMessage: true }),
function(req, res) {
res.redirect('/');
});
For a complete example, refer to the login example.
$ npm install --dev
$ make test