Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

rittaschool/passport-opinsys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

npm

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

The MIT License

Copyright (c) 2021-2021 Roni Äikäs <http://raikas.xyz/>

About

A opinsys strategy for Passport

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published