Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/celer/hopjs-oauth
OAuth support for HopJS
https://github.com/celer/hopjs-oauth
Last synced: about 24 hours ago
JSON representation
OAuth support for HopJS
- Host: GitHub
- URL: https://github.com/celer/hopjs-oauth
- Owner: celer
- Created: 2013-01-21T02:17:07.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-22T08:36:52.000Z (almost 12 years ago)
- Last Synced: 2024-12-04T18:54:41.248Z (18 days ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction
This is the oauth plugin for Hop.js (http://github.com/celer/hopjs)
To use this plugin simply use it like so
```javascript
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