github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

danwrong / merb_openid

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 17
    • 3
  • Source
  • Commits
  • Network (3)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

An OpenID Consumer plugin for Merb — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fixed dependency problems 
danwrong (author)
Thu Jan 08 15:15:16 -0800 2009
commit  c3b0506f7567ae3eb58bc5345c730c4dda66287f
tree    72636b1cde35919c15b52ba7c41343abd0a20568
parent  22f46ee56348d3a7427ee710afd3922260d28ece
merb_openid /
name age
history
message
file LICENSE Loading commit data...
file README
file Rakefile Wed Jun 25 08:20:16 -0700 2008 added a task for publishing to rubyforge [danwrong]
directory lib/
file merb_openid.gemspec Thu Jan 08 15:15:16 -0800 2009 fixed dependency problems [danwrong]
directory spec/
README
merb_openid
===========

A plugin for Merb that wraps the ruby-openid gem (2.x) and provides an easy interface for consuming OpenIDs
in a very similar way to the open_id_authentication plugin for Rails.

Installation
============

Easy:

   gem install merb_openid
   
Then in your application's init.rb:

   dependency 'merb_openid'
   
The plugin uses the pretty limited memory store by default but you can add a new store using Merb::Config:

   Merb::Config[:merb_openid][:store] = OpenID::Store::Memory.new
   
You'll probably want to use a database store on production apps.  I'll start adding adapters based on the
various ORMs soon.

Usage
=====

In your routes you need to make sure that the url you consume OpenIDs from can accept get requests, so:

   r.match('openid').(:controller => 'session', :action => 'openid')
   
Then in your controller:

  class Session < Merb::Controller
  
    def openid
      if openid_request? # has the user provided a url (openid_url)
        openid_authenticate do |result, identity_url|
          if result == :success
            user = User.find_by_openid_url(identity_url)
          end
        end
      end
    end
    
  end
  
SReg
====

Getting SReg data is easy too:

  class Session < Merb::Controller
  
    def openid
      if openid_request? # has the user provided a url (openid_url)
        openid_authenticate(:fields => [:fullname, :email]) do |result, identity_url, sreg|
          if result == :success
            user = User.find_by_openid_url(identity_url)
            user.name = sreg[:fullname]
          end
        end
      end
    end
    
  end
  
More to come!
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server