Permalink
Browse files

Some cleanups

  • Loading branch information...
1 parent 06ea370 commit f0eff1bf75764350a987243c29409d4ef24d35c3 @bergie committed Apr 17, 2012
View
@@ -1,18 +0,0 @@
-install npm modules:
-express, socket.io, underscore, backbone, connect, connect-auth, connect-redis, jsdom, browserify, request, jquery
-
-install redis-server
-
-install Palsu
-git clone git://github.com/bergie/ViePalsu.git
-
-cd ViePalsu
-create config file
-
-start redis
-coffee nodejs/palsu.coffee configfile.json
-
-
-===
-Authentication via Twitter API
--->
@@ -1,91 +0,0 @@
-/*!
- * Copyright(c) 2010 Stephen Belanger <admin@stephenbelanger.com>
- * MIT Licensed
- */
-var OAuth = require("oauth").OAuth,
- url = require("url"),
- connect = require("connect"),
- http = require('http');
-
-Linkedin = module.exports = function(options, server) {
- options = options || {}
- var that = {};
- var my = {};
-
- // Construct the internal OAuth client
- my._oAuth = new OAuth(
- "https://api.linkedin.com/uas/oauth/requestToken"
- , "https://api.linkedin.com/uas/oauth/accessToken"
- , options.consumerKey
- , options.consumerSecret
- , "1.0"
- , options.callback || null
- , "HMAC-SHA1"
- );
-
- // Give the strategy a name
- that.name = options.name || "linkedin";
-
- // Build the authentication routes required
- that.setupRoutes= function(server) {
- server.use('/', connect.router(function routes(app) {
- app.get('/auth/linkedin_callback', function(req, res) {
- req.authenticate([that.name], function(error, authenticated) {
- res.writeHead(303, {
- 'Location': req.session.linkedin_redirect_url
- });
- res.end('');
- });
- });
- }));
- }
-
- // Declare the method that actually does the authentication
- that.authenticate = function(request, response, callback) {
- //todo: if multiple connect middlewares were doing this, it would be more efficient to do it in the stack??
- var parsedUrl = url.parse(request.url, true);
-
- //todo: makw the call timeout ....
- var self = this;
- if (parsedUrl.query && parsedUrl.query.oauth_token && parsedUrl.query.oauth_verifier && request.session.auth["linkedin_oauth_token_secret"]) {
- my._oAuth.getOAuthAccessToken(parsedUrl.query.oauth_token, request.session.auth["linkedin_oauth_token_secret"], parsedUrl.query.oauth_verifier, function(error, token, secret, params) {
- if (error) {
- callback(null);
- } else {
- request.session.auth["linkedin_oauth_token_secret"] = secret;
- request.session.auth["linkedin_oauth_token"] = token;
-
- // Get user profile data.
- my._oAuth.getProtectedResource("https://api.linkedin.com/v1/people/~", 'get', token, secret, {'x-li-format':'json'}, function (error, data, response) {
- if (error) {
- self.fail(callback);
- } else {
- var result = JSON.parse(data);
- var user = {
- first_name: result.firstName
- , last_name: result.lastName
- , url: result.siteStandardProfileRequest.url
- , headline: result.headline
- };
- self.executionResult.user = user;
- self.success(user, callback);
- }
- })
- }
- });
- } else {
- my._oAuth.getOAuthRequestToken(function(error, token, secret, auth_url, params) {
- if (error) {
- callback(null); // Ignore the error upstream, treat as validation failure.
- } else {
- request.session['linkedin_redirect_url'] = request.url;
- request.session.auth["linkedin_oauth_token_secret"] = secret;
- request.session.auth["linkedin_oauth_token"] = token;
- self.redirect(response, "https://api.linkedin.com/uas/oauth/authorize?oauth_token=" + token, callback);
- }
- });
- }
- }
- return that;
-};
-
@@ -1,57 +0,0 @@
-/*!
- * Copyright(c) 2011 Stephen Belanger <admin@stephenbelanger.com>
- *
- * MIT Licensed
- */
-var openid = require("openid"),
- url = require("url"),
- connect = require("connect"),
- http = require('http'),
- querystring = require('querystring');
-
-module.exports = function(options, server) {
- options = options || {}
- var that = {};
- var my = {};
-
- // Generate OpenID relying party.
- my._relyingParty = new openid.RelyingParty(options.callback, null, false, false, []);
-
- // Give the strategy a name
- that.name = options.name || "openid";
-
- // Declare the method that actually does the authentication.
- that.authenticate = function(request, response, callback) {
- // Collect query info...
- var parsedUrl = url.parse(request.url, true);
-
- // Get self reference.
- var self = this;
-
- // Our identifier is in the query string, so we haven't authenticated yet.
- if (parsedUrl.query.openid_identifier) {
- request.session.openid_identifier = parsedUrl.query.openid_identifier;
- // Resolve identifier, associate, and build authentication URL
- my._relyingParty.authenticate(parsedUrl.query.openid_identifier, false, function(authUrl) {
- if ( ! authUrl) {
- callback(null);
- } else {
- self.redirect(response, authUrl, callback);
- }
- });
- } else {
- my._relyingParty.verifyAssertion(request, function(result) {
- if ( ! result.authenticated) {
- callback(null);
- } else {
- var user = {
- identifier: result.claimedIdentifier
- };
- self.executionResult.user = user;
- self.success(user, callback);
- }
- });
- }
- }
- return that;
-};
@@ -1,71 +0,0 @@
-/*!
- * Copyright(c) 2010 Ciaran Jessup <ciaranj@gmail.com>
- * MIT Licensed
- */
-var OAuth= require("oauth").OAuth,
- url = require("url"),
- connect = require("connect"),
- http = require('http');
-
-Twitter= module.exports= function(options, server) {
- options= options || {}
- var that= {};
- var my= {};
-
- // Construct the internal OAuth client
- my._oAuth= new OAuth("http://twitter.com/oauth/request_token",
- "http://twitter.com/oauth/access_token",
- options.consumerKey, options.consumerSecret,
- "1.0", options.callback || null, "HMAC-SHA1");
-
- // Give the strategy a name
- that.name = options.name || "twitter";
-
- // Build the authentication routes required
- that.setupRoutes= function(server) {
- server.use('/', connect.router(function routes(app){
- app.get('/auth/twitter_callback', function(req, res){
- req.authenticate([that.name], function(error, authenticated) {
- res.writeHead(303, { 'Location': req.session.twitter_redirect_url });
- res.end('');
- });
- });
- }));
- }
-
- // Declare the method that actually does the authentication
- that.authenticate= function(request, response, callback) {
- //todo: if multiple connect middlewares were doing this, it would be more efficient to do it in the stack??
- var parsedUrl= url.parse(request.url, true);
-
- //todo: makw the call timeout ....
- var self= this;
- if( parsedUrl.query && parsedUrl.query.oauth_token && request.session.auth["twitter_oauth_token_secret"] ) {
- my._oAuth.getOAuthAccessToken(parsedUrl.query.oauth_token, request.session.auth["twitter_oauth_token_secret"],
- function( error, oauth_token, oauth_token_secret, additionalParameters ) {
- if( error ) callback(null);
- else {
- request.session.auth["twitter_oauth_token_secret"]= oauth_token_secret;
- request.session.auth["twitter_oauth_token"]= oauth_token;
- var user= { user_id: additionalParameters.user_id,
- username: additionalParameters.screen_name }
- self.executionResult.user= user;
- self.success(user, callback)
- }
- });
- }
- else {
- my._oAuth.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, oauth_authorize_url, additionalParameters ) {
- if(error) {
- callback(null); // Ignore the error upstream, treat as validation failure.
- } else {
- request.session['twitter_redirect_url']= request.url;
- request.session.auth["twitter_oauth_token_secret"]= oauth_token_secret;
- request.session.auth["twitter_oauth_token"]= oauth_token;
- self.redirect(response, "http://twitter.com/oauth/authenticate?oauth_token=" + oauth_token, callback);
- }
- });
- }
- }
- return that;
-};
@@ -1,85 +0,0 @@
-/*!
- * Copyright(c) 2010 Stephen Belanger <admin@stephenbelanger.com>
- * MIT Licensed
- */
-var OAuth = require("oauth").OAuth,
- url = require("url"),
- connect = require("connect"),
- http = require('http');
-
-yammer = module.exports = function(options, server) {
- options = options || {}
- var that = {};
- var my = {};
-
- // Construct the internal OAuth client
- my._oAuth = new OAuth(
- "https://www.yammer.com/oauth/request_token"
- , "https://www.yammer.com/oauth/access_token"
- , options.consumerKey
- , options.consumerSecret
- , "1.0"
- , options.callback || null
- , "HMAC-SHA1"
- );
-
- // Give the strategy a name
- that.name = options.name || "yammer";
-
- // Build the authentication routes required
- that.setupRoutes= function(server) {
- server.use('/', connect.router(function routes(app) {
- app.get('/auth/yammer_callback', function(req, res) {
- req.authenticate([that.name], function(error, authenticated) {
- res.writeHead(303, {
- 'Location': req.session.yammer_redirect_url
- });
- res.end('');
- });
- });
- }));
- }
-
- // Declare the method that actually does the authentication
- that.authenticate = function(request, response, callback) {
- //todo: if multiple connect middlewares were doing this, it would be more efficient to do it in the stack??
- var parsedUrl = url.parse(request.url, true);
-
- //todo: makw the call timeout ....
- var self = this;
- if (parsedUrl.query && parsedUrl.query.oauth_token && parsedUrl.query.oauth_verifier && request.session.auth["yammer_oauth_token_secret"]) {
- my._oAuth.getOAuthAccessToken(parsedUrl.query.oauth_token, request.session.auth["yammer_oauth_token_secret"], parsedUrl.query.oauth_verifier, function(error, token, secret, params) {
- if (error) {
- callback(null);
- } else {
- request.session.auth["yammer_oauth_token_secret"] = secret;
- request.session.auth["yammer_oauth_token"] = token;
-
- // Get user profile data.
- my._oAuth.getProtectedResource("https://www.yammer.com/api/v1/groups.json", 'get', token, secret, function (error, data, response) {
- if (error) {
- self.fail(callback);
- } else {
- var result = JSON.parse(data);
- self.executionResult.user = result;
- self.success(result, callback);
- }
- })
- }
- });
- } else {
- my._oAuth.getOAuthRequestToken(function(error, token, secret, auth_url, params) {
- if (error) {
- callback(null); // Ignore the error upstream, treat as validation failure.
- } else {
- request.session['yammer_redirect_url'] = request.url;
- request.session.auth["yammer_oauth_token_secret"] = secret;
- request.session.auth["yammer_oauth_token"] = token;
- self.redirect(response, "https://www.yammer.com/oauth/authorize?oauth_token=" + token, callback);
- }
- });
- }
- }
- return that;
-};
-
Oops, something went wrong.

0 comments on commit f0eff1b

Please sign in to comment.