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

gplus-web-auth

v0.3.3

Published

Google Plus Login module for Node.js

Downloads

6

Readme

gplus-web-auth

Google+ login and authentication with client-side sessions for Node.js

Installation

Available via npm, to install it simply run the following line in your project:

npm install gplus-web-auth

Configuration

The module takes three parameters,

  1. Google+ credentials
  • A client ID. Create one on Google+ Developer Console and also configure whitelisted domains.
  • Configure the scope of permissions to ask for.
  • (optional) Configure a custom oauth2callback path, default is /oauth2callback.
  1. Session details
  • Configure the name of the cookie to use.
  • A random string to encrypt the cookies.
  • Duration of the token expiry
  • In case token is about to expire, extend the session for.
  1. Authorization method
  • A function that gets the user object from Google+ as the first parameter and a callback as second parameter. Simply return a truthy value on the callback method to authorise the user.
var auth = require('gplus-web-auth')({
  google: {
    client_id: "applicationid123.apps.googleusercontent.com",
    scope: ['profile', 'email'],
    callbackPath: "/custom/oauth2callback"
  },
  session: {
    cookieName: "gplusauth", // cookie name dictates the key name added to the request object
    secret: "secret", // should be a large unguessable string
    duration: 24 * 60 * 60 * 1000, // how long the session will stay valid in ms
    activeDuration: 1000 * 60 * 5 // if expiresIn < activeDuration, the session will be extended by activeDuration milliseconds
  },
  authorize: function(req, user, done){
    var authorized = (user.email.split('@')[1] === "application.com");
    done(authorized);
  }
});

Usage

Now simply use the auth object as a middleware on your app:

app.use(auth);

and use auth.verify middleware on routes that you wish should require authentication.

app.get('/admin', auth.verify, function(req, res) {
  res.render('index');
});

Calling app.use(auth) sets up this route on your app: /oauth2callback to use for authentication callbacks.

Caveats

Because this module uses client-side sessions - you do not need a session store on the server - hence easy to get up and running. But also you should not use Express's session middleware as it might conflict.

Author

Sunil Pai, [email protected]
Param Aggarwal, [email protected]

License

gplus-web-auth is available under the MIT license.