Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
/ passport-vipps Public archive

Passport strategy for Vipps Signup/Login. One-tap signup/login awesomeness for your Express apps! 🦄

License

Notifications You must be signed in to change notification settings

torfjor/passport-vipps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-vipps

Passport strategy for Vipps Signup/Login API

See example

WIP! Expect things to break! Also, Vipps is working on a new API in collaboration with BankID, replacing Signup/Login. No word on when this will be available, though. Your efforts may be wasted, you have been warned!

Install

npm install passport-vipps

Usage

Configure strategy

This strategy authenticates users using the Vipps Signup/Login API. Upon authentication, the Vipps Signup/Login API returns an URL to a portal hosted by Vipps (Desktop) or mobile app (iOS/Android), where the user is presented with a form to either accept or reject sharing their personal details with the issuing application. Upon accept, the user is redirected back to the application.

This strategy uses sessions to keep track of users' Vipps requests and to verify authentication attempts with the Signup/Login API when the users are redirected.

passport.use(new VippsStrategy({
    clientId: process.env.VIPPS_CLIENT_ID,
    clientSecret: process.env.VIPPS_CLIENT_SECRET,
    tokenKey: process.env.VIPPS_TOKEN_KEY,
    appKey: process.env.VIPPS_APP_KEY,
    merchantSerialNumber: process.env.VIPPS_MERCHANT_SERIAL_NUMBER,
    callbackUrl: 'https://vipps.localtunnel.me/auth/callback', // User redirect
    consentRemovalUrl: 'https://vipps.localtunnel.me/consentremoval', // TODO: Document this
    vippsCallback: 'http://vipps.localtunnel.me/auth/callback' // Vipps service callback TODO: Implement this
  },
  function (user, done) {
      User.findOrCreate(user)
        .then(user => {
          done(null, user)
        })
        .catch(error => {
          done(error, null)
        })
    }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'vipps' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/login',
  passport.authenticate('vipps'));

app.get('/auth/callback',
  passport.authenticate('vipps', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

License

The MIT License

Copyright (c) 2019 Torbjørn Hårstad Orskaug

About

Passport strategy for Vipps Signup/Login. One-tap signup/login awesomeness for your Express apps! 🦄

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published