passport-ldsauth / authentication strategy for Passport and Node.js



Passport strategy for authenticating with / using the OAuth 2.0 API.

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

npm install passport-ldsauth --save

The LDSAuth authentication strategy authenticates users using an account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a app ID, app secret, and callback URL.

passport.use(new LdsAuthStrategy({
    clientID: LDSAUTH_APP_ID,
    clientSecret: LDSAUTH_APP_SECRET,
    callbackURL: "http://localhost:3000/oauth2/ldsauth/callback"
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ ldsOrgId: profile.currentUserId }, function (err, user) {
      return done(err, user);

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

For example, as route middleware in an Express application:

, passport.authenticate('ldsauth')
// On success this falls through to the second route 
, passport.authenticate('ldsauth', { failureRedirect: '/login' })
, function (reqres) {
    // Successful authentication, redirect home. 

The MIT License

Copyright (c) 2014 AJ ONeal <>