public
Description: [pre-working] Plugin to assist in implementing an Openid server.
Clone URL: git://github.com/samsm/openid_server.git
name age message
file .gitignore Wed Jun 18 09:25:33 -0700 2008 Freeze, needs reworking. [Sam Schenkman-Moore]
file MIT-LICENSE Wed May 28 07:22:55 -0700 2008 Poached open_id_authentication's ActiveRecord s... [Sam Schenkman-Moore]
file README Thu Sep 25 08:24:26 -0700 2008 Small improvements and bug fixes. [Sam Schenkman-Moore]
file Rakefile Wed Apr 30 12:08:49 -0700 2008 first commit, generated plugin stuff [Sam Schenkman-Moore]
directory generators/ Fri Jun 20 11:47:17 -0700 2008 Freeze. [Sam Schenkman-Moore]
file init.rb Wed May 28 07:22:55 -0700 2008 Poached open_id_authentication's ActiveRecord s... [Sam Schenkman-Moore]
file install.rb Wed Apr 30 12:08:49 -0700 2008 first commit, generated plugin stuff [Sam Schenkman-Moore]
directory lib/ Thu Oct 02 12:15:11 -0700 2008 Transitions from verified -> verified allowed. [Sam Schenkman-Moore]
directory tasks/ Wed May 28 07:22:55 -0700 2008 Poached open_id_authentication's ActiveRecord s... [Sam Schenkman-Moore]
directory test/ Wed Apr 30 12:08:49 -0700 2008 first commit, generated plugin stuff [Sam Schenkman-Moore]
file uninstall.rb Wed Apr 30 12:08:49 -0700 2008 first commit, generated plugin stuff [Sam Schenkman-Moore]
README
OpenidProviderPlugin
============

This is a plugin to aid me (and maybe others) in adding openid provider functionality to their sites.

Much of the work is taken from or inspired by the JanRain openid library, the Apache Heraldy example, and also Dennis 
Blöte's masquerade. Oh yeah, and some fine poaching from the open_id_authentication plugin in Rails core.

Requires the ruby-openid gem, and aasm.
gem install ruby-openid
gem install rubyist-aasm --source http://gems.github.com

Example
=======

class ApplicationController < ActionController::Base
  ...
  include OpenidServer
  ...
end

class UsersController
  include OpenidServerResource
  
  before_filter :openid_routing, :only => :show
  skip_before_filter :verify_authenticity_token
  protected
    def attempt_approval
      # Just after this method ends, the plugin will call "current_request.approved?". 
      # Approved requests will be sent back to the relying party that originated them.
      # Non-approved requests with call "reconcile_non_approval", where you redirect to
      # a login page, or trust page.
      # example:
      if logged_in? and current_user == @user
        current_request.verify
      end
      if current_request.verified? and current_user.allows_openid_login
        current_request.approved
      end
    end
    
    def reconcile_non_approval
      case current_request.status
      when verified
        redirect_to manual_approval_path
      else
        redirect_to login_path
      end
    end
end

In a controller where you include OpenidServerResource the endpoint is assumed to be the resource requested. If you need 
to customize this (such as focusing on a given endpoint in a different controller) overwrite endpoint_url.

Example
=======

class TrustsController
  # ...
  protected
    def endpoint_url
      params[:endpoint_for_trust] or raise ErrorError
    end
end

You also need to adjust the routes so that POST requests to a given resource are accepted:

Example
=======

map.identity_endpoint 'identities/:id', :id => /.+/, :controller => 'identities', :action => 'show', :conditions => { 
:method => :post }
map.resources :identities



Copyright (c) 2008 Sam Schenkman-Moore, released under the MIT license