Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 68 lines (46 sloc) 1.637 kB
6d85eda @danwrong initial
authored
1 merb_openid
2 ===========
3
d0f352e @danwrong more in the README
authored
4 A plugin for Merb that wraps the ruby-openid gem (2.x) and provides an easy interface for consuming OpenIDs
5 in a very similar way to the open_id_authentication plugin for Rails.
6
7 Installation
8 ============
9
10 Easy:
11
518e9df @danwrong you can install from rubyforge now
authored
12 gem install merb_openid
d0f352e @danwrong more in the README
authored
13
14 Then in your application's init.rb:
15
16 dependency 'merb_openid'
17
18 The plugin uses the pretty limited memory store by default but you can add a new store using Merb::Config:
19
20 Merb::Config[:merb_openid][:store] = OpenID::Store::Memory.new
21
22 You'll probably want to use a database store on production apps. I'll start adding adapters based on the
23 various ORMs soon.
24
25 Usage
26 =====
27
28 In your routes you need to make sure that the url you consume OpenIDs from can accept get requests, so:
29
30 r.match('openid').(:controller => 'session', :action => 'openid')
31
32 Then in your controller:
33
34 class Session < Merb::Controller
35
36 def openid
37 if openid_request? # has the user provided a url (openid_url)
38 openid_authenticate do |result, identity_url|
39 if result == :success
40 user = User.find_by_openid_url(identity_url)
41 end
42 end
43 end
44 end
45
46 end
47
48 SReg
49 ====
50
51 Getting SReg data is easy too:
52
53 class Session < Merb::Controller
54
55 def openid
56 if openid_request? # has the user provided a url (openid_url)
57 openid_authenticate(:fields => [:fullname, :email]) do |result, identity_url, sreg|
58 if result == :success
59 user = User.find_by_openid_url(identity_url)
60 user.name = sreg[:fullname]
61 end
62 end
63 end
64 end
65
66 end
67
68 More to come!
Something went wrong with that request. Please try again.