Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Use RPX with Connect on top of Node.js
JavaScript
tree: 5c56e82949

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.rdoc
login.html
rpx.js

README.rdoc

connect-rpx.js

Use RPX with Connect:

Usage:

// Setup whatever require paths you need...
var Connect = require('connect');
var MemoryStore = require('connect/lib/connect/middleware/session/memory').MemoryStore;
var RPX = require( 'rpx' );

// Setup RPX 
// 
// Your API key, look in the settings on rpxnow.com
RPX.config( 'apiKey', 'abcefgehijk' );
// (Specify root paths to ignore, if you need to serve them for your login page)
RPX.config( 'ignorePaths', [ '/stylesheets', '/images', '/javascript', '/css' ] );
// This is where RPX will redirect you to once authentication has occurred
RPX.config( 'reentryPoint',  '/rpx_login' );
// This will remove the user auth session cookie, effectively logging you out.
RPX.config( 'logoutPoint',  '/logout' );
// The page which you use as a login page, see the sample login.html here.
RPX.config( 'loginPage',  '/static/login.html' );

// Setup your connect.  RPX requires session, cookieDecoder, redirect installed before RPX.
var minute = 60000;
var root = __dirname + "/public";
var Server = module.exports = Connect.createServer(
    Connect.logger(),
    Connect.bodyDecoder(),
    Connect.redirect(),
    Connect.cookieDecoder(),
    Connect.session({ store: new MemoryStore({ reapInterval: minute, maxAge: minute * 5 }) }),
    RPX.handler,
    Connect.staticProvider( root )  // this is not strictly required, 
                                    // but might be where you store login page and CSS, etc.
);
  • Then, run your app, and it should redirect to you the loginPath specified in the configuration.

  • Need to test locally? This will enable a random user login rather than going into RPX for authentication

  • allowing you to test while on a plane and simulate a login.

    // Add this after the last RPX.config line // DON'T FORGET TO REMOVE THIS IN PRODUCTION!!! RPX.config( 'fakedAuthentication', true );

TODO:

  • Remove dependency on restler

  • Add something to better handle errors or cancellations

  • Write test cases, I'm so embarassed to publish without them.…

THANKS

This code was based on the rack-rpx module

Something went wrong with that request. Please try again.