passport-opinsys
v1.0.0
Published
A [opinsys](https://api.opinsys.fi/v3/sso/developers) strategy for [Passport](https://www.npmjs.com/package/passport)
Downloads
5
Maintainers
Readme
passport-opinsys
Passport strategy for authenticating with opinsys
This module lets you authenticate using opinsys SSO in your Node.js applications. By plugging into Passport, opinsys authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-opinsys
Usage
Configure Strategy
The opinsys authentication strategy authenticates users using the opinsys SSO. The strategy requires a verify
callback, which accepts the user json (more info on opinsys API documentation) and calls done
providing a user.
passport.use(new OpinsysStrategy (
{
redirectURI: "http://localhost",
secret: "Opinsys JWT Secret Here!",
organization: "demo.opinsys.fi"
},
function(profile, done) {
if(profile.username !== "opiskelija.ritta") {
// User does not exists or other error
// done(error, user)
done("No user found", false)
} else {
// User exists.
done(null, {username: profile.username,id: profile.id})
}
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'opinsys'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.post('/login',
passport.authenticate('opinsys', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
License
Copyright (c) 2021-2021 Roni Äikäs <http://raikas.xyz/>