npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloudentity/passport-oauth2

v1.0.1

Published

OAuth 2.0 & OIDC authentication strategy for Passport.js using Cloudentity authorization platform

Downloads

5

Readme

Passport strategy for Cloudentity OAuth 2.0

Passport strategy for authenticating with Cloudentity using OAuth 2.0 & OIDC specifications. Cloudentity provides a world class FAPI certified multi tenant OAuth authorization server that will allow developers to create secure applications.

This module lets you authenticate using Cloudentity in your Node.js applications. By plugging into Passport, Cloudentity OAuth authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

npm install @cloudentity/passport-oauth2

Usage

Create an Application in Cloudentity

Before using @cloudentity/passport-cloudentity, you must register an application with Cloudentity. If you have not already done so, a new application can be created within Cloudentity. If you do not have an account, sign up for a free account at Cloudentity. Once an application is created, you will be issued a Client Identifier, Client secret , authorization server URL and callback URL which needs to be configured in the strategy as shown below. You will also need to configure a callback URL which matches the route in your application.

Configure Strategy in Nodejs application

The Cloudentity OAuth 2.0 authentication strategy authenticates users using Cloudentity that utilizes any of the underlying identity providers configured within the Cloudentity platform. Cloudentity platform issues OAuth & OIDC spec based access token and ID tokens to the Nodejs application. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a client ID, client secret, authorization server URL, and callback URL.

Note that clientSecret is not required in below configuration, if PKCE flow is utilized and is set to true.

var CloudentityStrategy = require('@cloudentity/passport-oauth2');

passport.use(new CloudentityStrategy({
    authServerURL: process.env.CLOUDENTITY_AUTH_SERVER,
    clientID: process.env.CLOUDENTITY_CLIENT_ID,
    clientSecret: process.env.CLOUDENTITY_CLIENT_SECRET,
    callbackURL: process.env.CLOUDENTITY_CALLBACK_URL,
    pkce: true,
    passReqToCallback   : true
  },
  function(req, accessToken, refreshToken, params, profile, done) {
    done(err, user);
  }
));

Authenticate Request in Nodejs application

To authenticate requests within this application, use the passport.authenticate() method specifying the cloudentity strategy.

app.get('/login',
  passport.authenticate('cloudentity', { 
    session: true,
    successReturnToOrRedirect: '/',
    scope: ['email', 'profile', 'openid']
  }
));

app.get( '/callback',
	passport.authenticate('cloudentity', {
		successRedirect: '/api/v1',
		failureRedirect: '/'
}));

Examples

Developers using the popular Express web framework can refer to the Express.js sample app that utilizes cloudentity strategy as a starting point for their own web applications.

License

The MIT License