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

passport-auth

v0.1.4

Published

Custom passport login service

Downloads

176

Readme

###Passport service login

  • Forked from social-login, with enhance

  • Add package ondemand, it mean will not add others passport-auth to your project

  • Update from passport-google to passport-google-auth

  • Support:

    • facebook
    • twitter
    • instagram
    • linkedin
    • github
    • google
    • amazon
    • dropbox
    • foursquare
    • imgur
    • meetup
    • wordpress
    • tumblr

Install

  • npm i passport-auth

Setup in express

  • app.route.js
'use strict';

const router = require('express').Router();

module.exports = authAPI;

function authAPI(app) {
  router.route('/api/auth/:type')
    .get(getAuth);
  router.route('/api/auth/:type/callback')
    .get( getAuthCallback);
  router.route('/api/auth/:type/fail')
    .get( getAuthFail);

  function getAuth(req, res) {
    res.jsonp({ message: "ok" });
  }
  function getAuthCallback(req, res) {
    res.jsonp({ message: "ok" });
  }
  function getAuthFail(req, res) {
    res.jsonp({ message: "ok" });
  }
  return router
}
  • app.auth.js
'use strict';
const Auth = require('passport-auth');

module.exports = function (app, config) {
  var auth = new auth({
    app: app,    					// ExpressJS instance
    url: config.url,	// Your root url
    onAuth: function(req, type, uniqueProperty, accessToken, refreshToken, profile, done) {
          // This is the centralized method that is called when the user is logged in using any of the supported social site.
          // Setup once and you're done.

        findOrCreate({
          profile: profile,			// Profile is the user's profile, already filtered to return only the parts that matter (no HTTP response code and that kind of useless data)
          property: uniqueProperty,	// What property in the data is unique: id, ID, name, ...
          type: type					// What type of login that is: facebook, foursquare, google, ...
        }, function(user) {
          done(null, user);		// Return the user and continue
        });
    }
  });

  // Setup the various services:
  auth.use({
    facebook:	{
      settings:	{
        clientID:		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET",
        authParameters:	{
          scope: 'read_stream,manage_pages'
        }
      },
      url:	{
        auth:		"/auth/facebook",           // The URL to use to login (<a href="/auth/facebook">Login with facebook</a>).
        callback: 	"/auth/facebook/callback",  // The Oauth callback url as specified in your facebook app's settings
        success:	'/',                        // Where to redirect the user once he's logged in
        fail:		'/auth/facebook/fail'       // Where to redirect the user if the login failed or was canceled.
      },
      options: {
        profileFields: ['id', 'displayName', 'photos', 'email']
      }
    },
    twitter:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/twitter",
        callback: 	"/auth/twitter/callback",
        success:	'/',
        fail:		'/auth/twitter/fail'
      }
    },
    instagram:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/instagram",
        callback: 	"/auth/instagram/callback",
        success:	'/',
        fail:		'/auth/instagram/fail'
      }
    },
    github:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/github",
        callback: 	"/auth/github/callback",
        success:	'/',
        fail:		'/auth/github/fail'
      }
    },
    linkedin:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET",
        authParameters:	{
          scope: ['r_basicprofile', 'r_emailaddress', 'r_fullprofile', 'r_contactinfo', 'r_network', 'rw_nus']
        }
      },
      url:	{
        auth:		"/auth/linkedin",
        callback: 	"/auth/linkedin/callback",
        success:	'/',
        fail:		'/auth/linkedin/fail'
      }
    },
    google:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/google",
        callback: 	"/auth/google/callback",
        success:	'/',
        fail:		'/auth/google/fail'
      }
    },
    amazon:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET",
        authParameters:	{
          scope: ['profile', 'postal_code']
        }
      },
      url:	{
        auth:		"/auth/amazon",
        callback: 	"/auth/amazon/callback",
        success:	'/',
        fail:		'/auth/amazon/fail'
      }
    },
    dropbox:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/dropbox",
        callback: 	"/auth/dropbox/callback",
        success:	'/',
        fail:		'/auth/dropbox/fail'
      }
    },
    foursquare:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/foursquare",
        callback: 	"/auth/foursquare/callback",
        success:	'/',
        fail:		'/auth/foursquare/fail'
      }
    },
    imgur:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/imgur",
        callback: 	"/auth/imgur/callback",
        success:	'/',
        fail:		'/auth/imgur/fail'
      }
    },
    meetup:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/meetup",
        callback: 	"/auth/meetup/callback",
        success:	'/',
        fail:		'/auth/meetup/fail'
      }
    },
    // http://developer.wordpress.com/docs/oauth2/
    wordpress:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/wordpress",
        callback: 	"/auth/wordpress/callback",
        success:	'/',
        fail:		'/auth/wordpress/fail'
      }
    },
    tumblr:	{
      settings:	{
        clientID: 		"YOUR_API_KEY",
        clientSecret: 	"YOUR_API_SECRET"
      },
      url:	{
        auth:		"/auth/tumblr",
        callback: 	"/auth/tumblr/callback",
        success:	'/',
        fail:		'/auth/tumblr/fail'
      }
    }
  });
}
  • server.js
'use strict';

const express = require('express');
const app = express();
const config = {
  url:'localhost:3000'
};

require('./app.auth.js')(app, config);

app.use('/api/auth/', require('./app.route')(app));