public
Description: A Ruby on Rails-based OpenID server for all ya identity providers out there. It is pretty close to the current OpenID specifications and supports SReg, AX (only fetch requests, yet) and PAPE
Homepage: http://dennisbloete.de/projects/masquerade/
Clone URL: git://github.com/dbloete/masquerade.git
Click here to lend your support to: masquerade and make a donation at www.pledgie.com !
Various fixes
dbloete (author)
Sun Jul 06 10:57:58 -0700 2008
commit  90fe7d439f1c6aaa1465bf93c82c310d7a18ec96
tree    a82614319fac99fb140d79897046a0d506ad98dc
parent  33ff1a2c866d1544b0aaa30fa4c21dd1b4a4b953
...
76
77
78
 
 
 
79
80
81
82
83
 
 
 
84
85
86
...
76
77
78
79
80
81
82
83
 
 
 
84
85
86
87
88
89
0
@@ -76,11 +76,14 @@ class ServerController < ApplicationController
0
       if params[:always]
0
         @site = current_account.sites.find_or_create_by_persona_id_and_url(params[:site][:persona_id], params[:site][:url])
0
         @site.update_attributes(params[:site])
0
+ elsif sreg_request || ax_fetch_request
0
+ @site = current_account.sites.find_or_initialize_by_persona_id_and_url(params[:site][:persona_id], params[:site][:url])
0
+ @site.attributes = params[:site]
0
       end
0
       resp = checkid_request.answer(true, nil, identifier(current_account))
0
- resp = add_pape(resp, [], nist_auth_level, current_openid_request.created_at)
0
- resp = add_sreg(resp, params[:site][:sreg]) if sreg_request && params[:site][:sreg]
0
- resp = add_ax(resp, transform_ax_data(params[:site][:ax])) if ax_fetch_request && params[:site][:ax]
0
+ resp = add_pape(resp, [], 2, current_openid_request.created_at)
0
+ resp = add_sreg(resp, @site.sreg_properties) if sreg_request && @site.sreg_properties
0
+ resp = add_ax(resp, @site.ax_properties) if ax_fetch_request && @site.ax_properties
0
       render_response(resp)
0
     end
0
   end
...
11
12
13
 
14
15
16
...
11
12
13
14
15
16
17
0
@@ -11,6 +11,7 @@
0
     <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
0
     <link rel="icon" href="/favicon.ico" type="image/ico" />
0
     <%= stylesheet_link_tag 'application' %>
0
+ <%= javascript_include_tag 'prototype' %>
0
   </head>
0
   <body>
0
     <div id="head">
...
1
2
 
 
 
 
 
 
 
 
 
3
4
 
5
6
7
8
9
 
10
11
12
13
14
15
16
17
18
 
19
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
68
69
70
71
72
73
74
 
75
76
77
78
79
80
81
 
 
...
1
 
2
3
4
5
6
7
8
9
10
11
 
12
13
14
 
 
 
15
16
 
17
18
19
20
21
22
 
23
24
25
26
27
28
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
60
61
62
63
 
64
65
66
67
68
69
70
71
 
72
73
0
@@ -1,81 +1,73 @@
0
 <h2>Identity request from <%=h extract_host(@site.url) %></h2>
0
-<p>The realm for this request is <strong><%=h checkid_request.trust_root %></strong></p>
0
+<% if sreg_request || ax_fetch_request %>
0
+<p><strong><%=h checkid_request.trust_root %></strong> requests some personal data.<br />
0
+Please select the information you would like to submit.</p>
0
+<p class="note">The attributes shown are from your persona <strong><%=h @site.persona.title %></strong>.<br />
0
+To submit other values you can <%= link_to "edit the persona", edit_account_persona_path(@site.persona, :return => decide_path(:persona_id => @site.persona.id)) %>
0
+or <%= link_to_function "choose another persona", 'Element.toggle("persona_select")' %>.</p>
0
+<% else %>
0
+<p><strong><%=h checkid_request.trust_root %></strong> requires your authentication.</p>
0
+<% end %>
0
 
0
-<% form_tag decide_path, :method => :get do %>
0
+<% form_tag decide_path, :method => :get, :id => 'persona_select', :style => 'display:none;' do %>
0
 
0
   <h3>Choose a persona</h3>
0
- <p><%=h extract_host(@site.url) %> requests your data.<br />
0
- Please select a persona to choose this data from.</p>
0
-
0
+ <% unless current_account.personas.empty? %>
0
   <div class="row">
0
- <%= content_tag :label, 'Persona', :for => 'persona_id' %>
0
     <select id="persona_id" name="persona_id">
0
       <%= options_from_collection_for_select(current_account.personas, :id, :title, @site.persona.id) %>
0
     </select>
0
   </div>
0
   <div>
0
     <%= submit_tag "choose persona" %> or
0
- <%= link_to "create new persona", new_account_persona_path(:return => decide_path) %>
0
+ <%= link_to "create a new persona", new_account_persona_path(:return => decide_path) %>
0
   </div>
0
+ <% end %>
0
   
0
 <% end if sreg_request || ax_fetch_request %>
0
 
0
 <% form_for @site, :url => complete_path do |f| %>
0
 
0
   <% if sreg_request || ax_fetch_request %>
0
- <h3><%=h @site.persona.title %> <span class="note"><%= link_to "edit persona", edit_account_persona_path(@site.persona, :return => decide_path(:persona_id => @site.persona.id)) %></span></h3>
0
- <p>Please choose the data that you would like to pass on.
0
- <%= link_to "#{h extract_host(@site.url)} privacy policy", sreg_request.policy_url unless !sreg_request || sreg_request.policy_url.blank? %></p>
0
-
0
- <% if sreg_request %>
0
- <table cellspacing="0">
0
- <tr>
0
- <th colspan="2"><h4>Simple Registration data</h4></th>
0
- <th>disclosure</th>
0
- </tr>
0
- <% (sreg_request.required + sreg_request.optional).each do |property| %>
0
- <tr>
0
- <td><%= label_tag "site_sreg_#{property}", property_label_text(property) %></td>
0
- <td><%= label_tag "site_sreg_#{property}", @site.persona.property(property) %></td>
0
- <td>
0
- <%= check_box_tag "site[sreg][#{property}]", @site.persona.property(property), sreg_request_for_field(property) == 'required', :id => "site_sreg_#{property}", :class => sreg_request_for_field(property) %>
0
- <%= label_tag "site_sreg_#{property}", sreg_request_for_field(property), :class => 'note' %>
0
- </td>
0
- </tr>
0
- <% end %>
0
- </table>
0
- <% end %>
0
- <% if ax_fetch_request %>
0
- <table cellspacing="0">
0
- <tr>
0
- <th colspan="2"><h4>Attribute Exchange</h4></th>
0
- <th>disclosure</th>
0
- </tr>
0
- <% ax_fetch_request.attributes.each do |property| %>
0
- <tr>
0
- <td><%= label_tag "site_ax_#{property.ns_alias}", property_label_text(property.ns_alias) %></td>
0
- <td><%= label_tag "site_ax_#{property.ns_alias}", @site.persona.property(property.type_uri) %></td>
0
- <td>
0
- <%= check_box_tag "site[ax][#{property.ns_alias}][value]", @site.persona.property(property.type_uri), ax_request_for_field(property) == 'required', :id => "site_ax_#{property.ns_alias}", :class => ax_request_for_field(property) %>
0
- <%= hidden_field_tag "site[ax][#{property.ns_alias}][type]", property.type_uri, :id => "site_ax_type_#{property.ns_alias}" %>
0
- <%= label_tag "site_ax_#{property.ns_alias}", ax_request_for_field(property), :class => 'note' %>
0
- </td>
0
- </tr>
0
- <% end %>
0
- </table>
0
- <% end %>
0
+ <table cellspacing="0">
0
+ <tr>
0
+ <th colspan="2"><h4>Requested information</h4></th>
0
+ <th class="disclosure">disclosure</th>
0
+ </tr>
0
+ <% (sreg_request.required + sreg_request.optional).each do |property| %>
0
+ <tr>
0
+ <td><%= label_tag "site_sreg_#{property}", property_label_text(property) %></td>
0
+ <td><%= label_tag "site_sreg_#{property}", @site.persona.property(property) %></td>
0
+ <td>
0
+ <%= check_box_tag "site[sreg][#{property}]", @site.persona.property(property), sreg_request.required.include?(property), :id => "site_sreg_#{property}", :class => sreg_request_for_field(property) %>
0
+ <%= label_tag "site_sreg_#{property}", sreg_request_for_field(property), :class => 'note' %>
0
+ </td>
0
+ </tr>
0
+ <% end if sreg_request %>
0
+ <% ax_fetch_request.attributes.each do |property| %>
0
+ <tr>
0
+ <td><%= label_tag "site_ax_#{property.ns_alias}", property.ns_alias %></td>
0
+ <td><%= label_tag "site_ax_#{property.ns_alias}", @site.persona.property(property.type_uri) %></td>
0
+ <td>
0
+ <%= check_box_tag "site[ax][#{property.ns_alias}][value]", @site.persona.property(property.type_uri), property.required, :id => "site_ax_#{property.ns_alias}", :class => ax_request_for_field(property) %>
0
+ <%= hidden_field_tag "site[ax][#{property.ns_alias}][type]", property.type_uri, :id => "site_ax_type_#{property.ns_alias}" %>
0
+ <%= label_tag "site_ax_#{property.ns_alias}", ax_request_for_field(property), :class => 'note' %>
0
+ </td>
0
+ </tr>
0
+ <% end if ax_fetch_request %>
0
+ </table>
0
   <% end %>
0
-
0
   <div>
0
     <% if sreg_request || ax_fetch_request %>
0
     <%= f.hidden_field :persona_id %>
0
     <%= f.hidden_field :url %>
0
- <%= submit_tag 'Always trust this site', :name => 'always', :class => 'space' %>
0
     <%= submit_tag 'Trust this site only this time', :name => 'temporary', :class => 'space' %>
0
+ <%= submit_tag 'Always trust this site', :name => 'always', :class => 'space' %>
0
     <% else %>
0
     <%= submit_tag 'Approve this request', :name => 'temporary', :class => 'space' %>
0
     <% end %>
0
     <%= submit_tag 'Cancel this request', :name => 'cancel' %>
0
   </div>
0
   
0
-<% end %>
0
+<% end unless current_account.personas.empty? %>
0
+
...
1
2
3
 
 
4
5
6
...
9
10
11
12
13
14
15
16
17
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
21
22
...
1
 
 
2
3
4
5
6
...
9
10
11
 
 
 
 
 
 
 
 
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -1,6 +1,6 @@
0
 xml.instruct!
0
-xml.opConfig(:version => '1.0') do
0
- xml.configRevision('2008050101')
0
+xml.opConfig(:version => '1.0', :serverIdentifier => endpoint_url) do
0
+ xml.configRevision('2008070601')
0
   xml.title(APP_CONFIG['name'])
0
   xml.serverIdentifier(endpoint_url)
0
   xml.opDomain(APP_CONFIG['host'])
0
@@ -9,13 +9,16 @@ xml.opConfig(:version => '1.0') do
0
   xml.loginUrl(login_url(:protocol => scheme))
0
   xml.welcomeUrl(home_url(:protocol => scheme))
0
   xml.loginStateUrl(formatted_seatbelt_state_url(:protocol => scheme, :format => :xml))
0
- xml.toolbarGrayBackground('#e0e0e0')
0
- xml.toolbarGrayBorder('#a0a0a0')
0
- xml.toolbarGrayText('#505050')
0
- xml.toolbarLoginBackground('#a7e0fb')
0
- xml.toolbarLoginBorder('#a0a0a0')
0
- xml.toolbarLoginText('#000000')
0
- xml.toolbarHighBackground('#f2db8b')
0
- xml.toolbarHighBorder('#22ab1b')
0
- xml.toolbarHighText('#22ab1b')
0
+ xml.settingsIconUrl("#{home_url(:protocol => scheme)}images/seatbealt_icon.png")
0
+ xml.toolbarGrayIconUrl("#{home_url(:protocol => scheme)}images/seatbealt_icon_gray.png")
0
+ xml.toolbarHighIconUrl("#{home_url(:protocol => scheme)}images/seatbealt_icon_high.png")
0
+ xml.toolbarGrayBackground('#EBEBEB')
0
+ xml.toolbarGrayBorder('#666666')
0
+ xml.toolbarGrayText('#666666')
0
+ xml.toolbarLoginBackground('#EBEBEB')
0
+ xml.toolbarLoginBorder('#2B802B')
0
+ xml.toolbarLoginText('#2B802B')
0
+ xml.toolbarHighBackground('#EBEBEB')
0
+ xml.toolbarHighBorder('#F50012')
0
+ xml.toolbarHighText('#F50012')
0
 end
0
\ No newline at end of file
...
1
2
3
 
4
5
...
1
2
 
3
4
5
0
@@ -1,4 +1,4 @@
0
 xml.instruct!
0
 xml.personaConfig(:serverIdentifier => endpoint_url, :version => '1.0') do
0
- xml.persona(identifier(current_account)) if logged_in?
0
+ xml.persona(identifier(current_account), :displayName => current_account.login) if logged_in?
0
 end
0
\ No newline at end of file
...
34
35
36
37
 
38
39
...
34
35
36
 
37
38
39
0
@@ -34,5 +34,5 @@ Rails::Initializer.run do |config|
0
   
0
   # Gems
0
   config.gem 'ruby-openid', :lib => 'openid', :version => '2.0.4'
0
- config.gem 'ruby-yadis', :lib => 'yadis' , :version => '0.3.4'
0
+ config.gem 'ruby-yadis', :lib => 'yadis', :version => '0.3.4'
0
 end
0
\ No newline at end of file
...
25
26
27
 
 
28
29
30
...
34
35
36
37
 
38
39
40
41
42
43
44
45
 
46
47
48
 
49
50
51
...
99
100
101
 
 
102
103
104
...
115
116
117
118
 
 
119
120
121
 
 
122
123
124
125
126
 
 
127
128
129
...
144
145
146
147
 
148
149
150
...
25
26
27
28
29
30
31
32
...
36
37
38
 
39
40
41
42
43
44
45
 
 
46
47
48
 
49
50
51
52
...
100
101
102
103
104
105
106
107
...
118
119
120
 
121
122
123
 
 
124
125
126
127
128
 
 
129
130
131
132
133
...
148
149
150
 
151
152
153
154
0
@@ -25,6 +25,8 @@ class OpenidUserStoriesTest < ActionController::IntegrationTest
0
   end
0
   
0
   def test_providing_sreg_data
0
+ @account = accounts(:standard)
0
+ @persona = @account.personas.first
0
     claimed_id = "http://www.example.com/quentin"
0
     request_params = checkid_request_params.merge(
0
       'openid.identity' => claimed_id,
0
@@ -34,18 +36,17 @@ class OpenidUserStoriesTest < ActionController::IntegrationTest
0
     post '/server', request_params
0
     # User has to log in
0
     assert_redirected_to safe_login_url
0
- post '/session', :login => 'quentin', :password => 'test'
0
+ post '/session', :login => @account.login, :password => 'test'
0
     # User has to verify the request
0
     assert_redirected_to proceed_url
0
     follow_redirect!
0
     assert_redirected_to decide_url
0
     follow_redirect!
0
     assert_template 'server/decide'
0
- post 'server/complete', :temporary => 1,
0
- :site => { :sreg => { 'nickname' => 'Test' } }
0
+ post 'server/complete', :temporary => 1, :site => { :persona_id => @persona.id, :sreg => { 'nickname' => @persona.nickname } }
0
     assert @response.redirect_url_match?(checkid_request_params['openid.return_to'])
0
     assert @response.redirect_url_match?("openid.mode=id_res")
0
- assert @response.redirect_url_match?("openid.sreg.nickname=Test"), "Response was expected to have SReg nickname"
0
+ assert @response.redirect_url_match?("openid.sreg.nickname=#{@persona.nickname}"), "Response was expected to have SReg nickname"
0
   end
0
 
0
   def test_responding_to_immidiate_requests_when_already_logged_in
0
@@ -99,6 +100,8 @@ class OpenidUserStoriesTest < ActionController::IntegrationTest
0
   end
0
   
0
   def test_providing_ax_data
0
+ @account = accounts(:standard)
0
+ @persona = @account.personas.first
0
     claimed_id = "http://www.example.com/quentin"
0
     request_params = checkid_request_params.merge(
0
       'openid.identity' => claimed_id,
0
@@ -115,15 +118,16 @@ class OpenidUserStoriesTest < ActionController::IntegrationTest
0
     assert_redirected_to decide_url
0
     follow_redirect!
0
     assert_template 'server/decide'
0
- post 'server/complete', :temporary => 1, :site => {
0
+ post 'server/complete', :temporary => 1, :site => {
0
+ :persona_id => @persona.id,
0
       :ax => {
0
- 'fullname' => { 'type' => 'http://axschema.org/namePerson', 'value' => 'Testmann' },
0
- 'gender' => { 'type' => 'http://axschema.org/person/gender', 'value' => 'M' } } }
0
+ 'nickname' => { 'type' => 'http://axschema.org/namePerson/friendly', 'value' => @persona.nickname },
0
+ 'gender' => { 'type' => 'http://axschema.org/person/gender', 'value' => @persona.gender } } }
0
     assert @response.redirect_url_match?(checkid_request_params['openid.return_to'])
0
     assert @response.redirect_url_match?("openid.mode=id_res"), "Response mode was expected to be id_res"
0
     assert @response.redirect_url_match?("openid.ax.mode=fetch_response"), "AX mode was expected to be fetch_response"
0
- assert @response.redirect_url_match?("Testmann"), "Response was expected to have AX fullname: #{@response.redirect_url}"
0
- assert @response.redirect_url_match?("M"), "Response was expected to have AX gender: #{@response.redirect_url}"
0
+ assert @response.redirect_url_match?(@persona.nickname), "Response was expected to have AX nickname: #{@response.redirect_url}"
0
+ assert @response.redirect_url_match?(@persona.gender), "Response was expected to have AX gender: #{@response.redirect_url}"
0
   end
0
   
0
   def test_responding_to_pape_requests
0
@@ -144,7 +148,7 @@ class OpenidUserStoriesTest < ActionController::IntegrationTest
0
     follow_redirect!
0
     assert_template 'server/decide'
0
     post 'server/complete', :temporary => 1
0
- assert @response.redirect_url_match?(checkid_request_params['openid.return_to'])
0
+ assert @response.redirect_url_match?(checkid_request_params['openid.return_to']), "Redirected to: #{@response.redirect_url}"
0
     assert @response.redirect_url_match?("openid.mode=id_res"), "Response mode was expected to be id_res"
0
     assert @response.redirect_url_match?("openid.pape.auth_policies=")
0
     assert @response.redirect_url_match?("openid.pape.auth_age="), "Response was expected to have PAPE Auth Age: #{@response.redirect_url}"
...
100
101
102
103
 
104
105
 
106
107
108
...
100
101
102
 
103
104
 
105
106
107
108
0
@@ -100,9 +100,9 @@ class Test::Unit::TestCase
0
   def ax_fetch_request_params
0
     { 'openid.ns.ax' => OpenID::AX::AXMessage::NS_URI,
0
       'openid.ax.mode' => 'fetch_request',
0
- 'openid.ax.type.fullname' => 'http://axschema.org/namePerson',
0
+ 'openid.ax.type.nickname' => 'http://axschema.org/namePerson/friendly',
0
       'openid.ax.type.gender' => 'http://axschema.org/person/gender',
0
- 'openid.ax.required' => 'fullname',
0
+ 'openid.ax.required' => 'nickname',
0
       'openid.ax.if_available' => 'gender',
0
       'openid.ax.update_url' => 'http://test.com/update' }
0
   end

Comments

    No one has commented yet.