Code Monkey home page Code Monkey logo

passport-oidc-example's Introduction

Passport OIDC Example

This is a simple Node.js/ExpressJS app to demonstrate OIDC federation with CitizenOne™ or any other OIDC provider. It uses Passport for handling authentication and sessions. Specifically, it uses the passport-openidconnect authentication strategy.

Running the app

Install the dependencies

npm install

Configuration

You will need to configure the application to talk to your instance of CitizenOne™. The only changes that should be required are in app.js. Update the following snippet of code with your issuer, authorization URL, token URL, user info URL, client id and client secret. The callback URL and scopes should not need to be updated.

  passport.use('oidc', new OidcStrategy({
    issuer: 'https://c1dev.vivvo.com/',
    authorizationURL: 'https://c1dev.vivvo.com/oauth/v2/authorize',
    tokenURL: 'https://c1dev.vivvo.com/oauth/v2/token',
    userInfoURL: 'https://c1dev.vivvo.com/oauth/v2/userinfo',
    clientID: '41209adf-45e9-4d1b-8720-8c6a1e680ceb',
    clientSecret: 'd18a3ba5-e7be-4da6-857d-333e5cf6e794',
    callbackURL: 'http://localhost:3000/authorization-code/callback',
    scope: 'openid profile email phone address'
  }, (issuer, sub, profile, accessToken, refreshToken, done) => {
    return done(null, profile)
  }))

Starting the app

npm start

In your favourite browser, head to http://localhost:3000 and hit the login button to start the login flow. Once you are logged in, you will see a page with the profile information returned from CitizenOne™.

passport-oidc-example's People

Contributors

frozentoes avatar lucastetreault avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.