Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hopjs-oauth

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hopjs-oauth

OAuth2 provider support for hopjs

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

This is the oauth plugin for Hop.js (http://github.com/celer/hopjs)

To use this plugin simply use it like so


var Hop = require('hopjs');

Hop.use(require('hopjs-oauth'));

//This function when provided with a user object will return the id of the user
var getUserId=function(){ ...}

var provider = Hop.useOAuth({ 
	crypt_key:"foo",
	sign_key:"bar",
	loginURL: "/login",	
	grantStore: new Hop.RedisGrantStore({ redisClient: redisClient, getUserId: getUserId }),
	accessToken:function(req,token,next){
		console.log("Access token request",token);
		
		loadUserById(token.user_id, function(err,user){
			if(user){
				req.session.user=user;
				next();
			} else {
				next(new Error("Unable to load user"));
			}
		});
	}
});


var app = express();
app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('your secret here'));
  app.use(express.session());
	app.use(provider.oauth());
	app.use(provider.login());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});

See http://github.com/celer/hopjs-oauth/tree/master/examples/provider and http://github.com/celer/hopjs-oauth/tree/master/examples/consumer for working examples

Keywords

FAQs

Package last updated on 22 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc