panjiva-oauth-plugin 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +12 -0
  3. data/CHANGELOG +178 -0
  4. data/Gemfile +27 -0
  5. data/Guardfile +8 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +531 -0
  8. data/Rakefile +2 -0
  9. data/UPGRADE.rdoc +21 -0
  10. data/generators/oauth_consumer/USAGE +10 -0
  11. data/generators/oauth_consumer/oauth_consumer_generator.rb +50 -0
  12. data/generators/oauth_consumer/templates/consumer_token.rb +11 -0
  13. data/generators/oauth_consumer/templates/controller.rb +27 -0
  14. data/generators/oauth_consumer/templates/index.html.erb +29 -0
  15. data/generators/oauth_consumer/templates/index.html.haml +18 -0
  16. data/generators/oauth_consumer/templates/migration.rb +20 -0
  17. data/generators/oauth_consumer/templates/oauth_config.rb +73 -0
  18. data/generators/oauth_consumer/templates/show.html.erb +7 -0
  19. data/generators/oauth_consumer/templates/show.html.haml +8 -0
  20. data/generators/oauth_provider/USAGE +20 -0
  21. data/generators/oauth_provider/lib/insert_routes.rb +67 -0
  22. data/generators/oauth_provider/oauth_provider_generator.rb +127 -0
  23. data/generators/oauth_provider/templates/_form.html.erb +17 -0
  24. data/generators/oauth_provider/templates/_form.html.haml +21 -0
  25. data/generators/oauth_provider/templates/access_token.rb +16 -0
  26. data/generators/oauth_provider/templates/authorize.html.erb +14 -0
  27. data/generators/oauth_provider/templates/authorize.html.haml +16 -0
  28. data/generators/oauth_provider/templates/authorize_failure.html.erb +1 -0
  29. data/generators/oauth_provider/templates/authorize_failure.html.haml +1 -0
  30. data/generators/oauth_provider/templates/authorize_success.html.erb +1 -0
  31. data/generators/oauth_provider/templates/authorize_success.html.haml +1 -0
  32. data/generators/oauth_provider/templates/client_application.rb +57 -0
  33. data/generators/oauth_provider/templates/client_application_spec.rb +29 -0
  34. data/generators/oauth_provider/templates/client_application_test.rb +42 -0
  35. data/generators/oauth_provider/templates/client_applications.yml +23 -0
  36. data/generators/oauth_provider/templates/clients_controller.rb +52 -0
  37. data/generators/oauth_provider/templates/clients_controller_spec.rb +176 -0
  38. data/generators/oauth_provider/templates/clients_controller_test.rb +280 -0
  39. data/generators/oauth_provider/templates/controller.rb +23 -0
  40. data/generators/oauth_provider/templates/edit.html.erb +7 -0
  41. data/generators/oauth_provider/templates/edit.html.haml +4 -0
  42. data/generators/oauth_provider/templates/index.html.erb +43 -0
  43. data/generators/oauth_provider/templates/index.html.haml +39 -0
  44. data/generators/oauth_provider/templates/migration.rb +47 -0
  45. data/generators/oauth_provider/templates/new.html.erb +5 -0
  46. data/generators/oauth_provider/templates/new.html.haml +5 -0
  47. data/generators/oauth_provider/templates/oauth2_authorize.html.erb +16 -0
  48. data/generators/oauth_provider/templates/oauth2_authorize.html.haml +17 -0
  49. data/generators/oauth_provider/templates/oauth2_token.rb +20 -0
  50. data/generators/oauth_provider/templates/oauth2_token_spec.rb +52 -0
  51. data/generators/oauth_provider/templates/oauth2_verifier.rb +35 -0
  52. data/generators/oauth_provider/templates/oauth2_verifier_spec.rb +44 -0
  53. data/generators/oauth_provider/templates/oauth_nonce.rb +13 -0
  54. data/generators/oauth_provider/templates/oauth_nonce_spec.rb +24 -0
  55. data/generators/oauth_provider/templates/oauth_nonce_test.rb +26 -0
  56. data/generators/oauth_provider/templates/oauth_nonces.yml +13 -0
  57. data/generators/oauth_provider/templates/oauth_token.rb +30 -0
  58. data/generators/oauth_provider/templates/oauth_token_spec.rb +309 -0
  59. data/generators/oauth_provider/templates/oauth_token_test.rb +57 -0
  60. data/generators/oauth_provider/templates/oauth_tokens.yml +17 -0
  61. data/generators/oauth_provider/templates/request_token.rb +40 -0
  62. data/generators/oauth_provider/templates/show.html.erb +27 -0
  63. data/generators/oauth_provider/templates/show.html.haml +30 -0
  64. data/init.rb +1 -0
  65. data/install.rb +2 -0
  66. data/lib/generators/active_record/oauth_consumer_generator.rb +33 -0
  67. data/lib/generators/active_record/oauth_consumer_templates/consumer_token.rb +11 -0
  68. data/lib/generators/active_record/oauth_consumer_templates/migration.rb +20 -0
  69. data/lib/generators/active_record/oauth_provider_generator.rb +39 -0
  70. data/lib/generators/active_record/oauth_provider_templates/access_token.rb +16 -0
  71. data/lib/generators/active_record/oauth_provider_templates/client_application.rb +57 -0
  72. data/lib/generators/active_record/oauth_provider_templates/migration.rb +47 -0
  73. data/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb +20 -0
  74. data/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb +35 -0
  75. data/lib/generators/active_record/oauth_provider_templates/oauth_nonce.rb +13 -0
  76. data/lib/generators/active_record/oauth_provider_templates/oauth_token.rb +30 -0
  77. data/lib/generators/active_record/oauth_provider_templates/request_token.rb +40 -0
  78. data/lib/generators/erb/oauth_consumer_generator.rb +14 -0
  79. data/lib/generators/erb/oauth_consumer_templates/index.html.erb +29 -0
  80. data/lib/generators/erb/oauth_consumer_templates/show.html.erb +7 -0
  81. data/lib/generators/erb/oauth_provider_generator.rb +23 -0
  82. data/lib/generators/erb/oauth_provider_templates/_form.html.erb +17 -0
  83. data/lib/generators/erb/oauth_provider_templates/authorize.html.erb +14 -0
  84. data/lib/generators/erb/oauth_provider_templates/authorize_failure.html.erb +1 -0
  85. data/lib/generators/erb/oauth_provider_templates/authorize_success.html.erb +1 -0
  86. data/lib/generators/erb/oauth_provider_templates/edit.html.erb +7 -0
  87. data/lib/generators/erb/oauth_provider_templates/index.html.erb +43 -0
  88. data/lib/generators/erb/oauth_provider_templates/new.html.erb +5 -0
  89. data/lib/generators/erb/oauth_provider_templates/oauth2_authorize.html.erb +16 -0
  90. data/lib/generators/erb/oauth_provider_templates/show.html.erb +27 -0
  91. data/lib/generators/haml/oauth_consumer_generator.rb +21 -0
  92. data/lib/generators/haml/oauth_consumer_templates/index.html.haml +18 -0
  93. data/lib/generators/haml/oauth_consumer_templates/show.html.haml +8 -0
  94. data/lib/generators/haml/oauth_provider_generator.rb +28 -0
  95. data/lib/generators/haml/oauth_provider_templates/_form.html.haml +21 -0
  96. data/lib/generators/haml/oauth_provider_templates/authorize.html.haml +16 -0
  97. data/lib/generators/haml/oauth_provider_templates/authorize_failure.html.haml +1 -0
  98. data/lib/generators/haml/oauth_provider_templates/authorize_success.html.haml +1 -0
  99. data/lib/generators/haml/oauth_provider_templates/edit.html.haml +4 -0
  100. data/lib/generators/haml/oauth_provider_templates/index.html.haml +39 -0
  101. data/lib/generators/haml/oauth_provider_templates/new.html.haml +5 -0
  102. data/lib/generators/haml/oauth_provider_templates/oauth2_authorize.html.haml +17 -0
  103. data/lib/generators/haml/oauth_provider_templates/show.html.haml +30 -0
  104. data/lib/generators/mongoid/oauth_consumer_generator.rb +15 -0
  105. data/lib/generators/mongoid/oauth_consumer_templates/consumer_token.rb +41 -0
  106. data/lib/generators/mongoid/oauth_provider_generator.rb +21 -0
  107. data/lib/generators/mongoid/oauth_provider_templates/access_token.rb +16 -0
  108. data/lib/generators/mongoid/oauth_provider_templates/client_application.rb +71 -0
  109. data/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb +20 -0
  110. data/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb +35 -0
  111. data/lib/generators/mongoid/oauth_provider_templates/oauth_nonce.rb +24 -0
  112. data/lib/generators/mongoid/oauth_provider_templates/oauth_token.rb +44 -0
  113. data/lib/generators/mongoid/oauth_provider_templates/request_token.rb +36 -0
  114. data/lib/generators/oauth_consumer/USAGE +11 -0
  115. data/lib/generators/oauth_consumer/oauth_consumer_generator.rb +31 -0
  116. data/lib/generators/oauth_consumer/templates/controller.rb +59 -0
  117. data/lib/generators/oauth_consumer/templates/oauth_config.rb +68 -0
  118. data/lib/generators/oauth_inflections.rb +6 -0
  119. data/lib/generators/oauth_plugin.rb +0 -0
  120. data/lib/generators/oauth_provider/USAGE +18 -0
  121. data/lib/generators/oauth_provider/oauth_provider_generator.rb +37 -0
  122. data/lib/generators/oauth_provider/templates/clients_controller.rb +52 -0
  123. data/lib/generators/oauth_provider/templates/controller.rb +23 -0
  124. data/lib/generators/rspec/oauth_provider_generator.rb +35 -0
  125. data/lib/generators/rspec/templates/client_application_spec.rb +29 -0
  126. data/lib/generators/rspec/templates/client_applications.yml +23 -0
  127. data/lib/generators/rspec/templates/clients_controller_spec.rb +176 -0
  128. data/lib/generators/rspec/templates/oauth2_token_spec.rb +52 -0
  129. data/lib/generators/rspec/templates/oauth2_verifier_spec.rb +44 -0
  130. data/lib/generators/rspec/templates/oauth_nonce_spec.rb +24 -0
  131. data/lib/generators/rspec/templates/oauth_nonces.yml +13 -0
  132. data/lib/generators/rspec/templates/oauth_token_spec.rb +309 -0
  133. data/lib/generators/rspec/templates/oauth_tokens.yml +17 -0
  134. data/lib/generators/test_unit/oauth_provider_generator.rb +33 -0
  135. data/lib/generators/test_unit/templates/client_application_test.rb +42 -0
  136. data/lib/generators/test_unit/templates/client_applications.yml +23 -0
  137. data/lib/generators/test_unit/templates/clients_controller_test.rb +280 -0
  138. data/lib/generators/test_unit/templates/oauth_nonce_test.rb +26 -0
  139. data/lib/generators/test_unit/templates/oauth_nonces.yml +13 -0
  140. data/lib/generators/test_unit/templates/oauth_token_test.rb +57 -0
  141. data/lib/generators/test_unit/templates/oauth_tokens.yml +17 -0
  142. data/lib/oauth-plugin.rb +24 -0
  143. data/lib/oauth-plugin/version.rb +5 -0
  144. data/lib/oauth/controllers/application_controller_methods.rb +136 -0
  145. data/lib/oauth/controllers/consumer_controller.rb +150 -0
  146. data/lib/oauth/controllers/provider_controller.rb +181 -0
  147. data/lib/oauth/models/consumers/service_loader.rb +28 -0
  148. data/lib/oauth/models/consumers/services/agree2_token.rb +15 -0
  149. data/lib/oauth/models/consumers/services/fireeagle_token.rb +39 -0
  150. data/lib/oauth/models/consumers/services/google_token.rb +21 -0
  151. data/lib/oauth/models/consumers/services/oauth2_token.rb +27 -0
  152. data/lib/oauth/models/consumers/services/opentransact_token.rb +15 -0
  153. data/lib/oauth/models/consumers/services/picomoney_token.rb +17 -0
  154. data/lib/oauth/models/consumers/services/twitter_token.rb +24 -0
  155. data/lib/oauth/models/consumers/simple_client.rb +50 -0
  156. data/lib/oauth/models/consumers/token.rb +93 -0
  157. data/lib/oauth/provider/authorizer.rb +83 -0
  158. data/lib/oauth/rack/oauth_filter.rb +93 -0
  159. data/oauth-plugin.gemspec +39 -0
  160. data/rails/init.rb +1 -0
  161. data/spec/dummy_provider_models.rb +53 -0
  162. data/spec/oauth/provider/authorizer_spec.rb +202 -0
  163. data/spec/rack/oauth_filter_spec.rb +244 -0
  164. data/spec/spec_helper.rb +3 -0
  165. data/tasks/oauth_tasks.rake +4 -0
  166. data/uninstall.rb +1 -0
  167. metadata +362 -0
@@ -0,0 +1,280 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.dirname(__FILE__) + '/../oauth_controller_test_helper'
3
+ require 'oauth/client/action_controller_request'
4
+
5
+ class OauthClientsController; def rescue_action(e) raise e end; end
6
+
7
+ class OauthClientsControllerIndexTest < ActionController::TestCase
8
+ include OAuthControllerTestHelper
9
+ tests OauthClientsController
10
+
11
+ def setup
12
+ @controller = OauthClientsController.new
13
+ @request = ActionController::TestRequest.new
14
+ @response = ActionController::TestResponse.new
15
+
16
+ login_as_application_owner
17
+ end
18
+
19
+ def do_get
20
+ get :index
21
+ end
22
+
23
+ def test_should_be_successful
24
+ do_get
25
+ assert @response.success?
26
+ end
27
+
28
+ def test_should_query_current_users_client_applications
29
+ @user.expects(:client_applications).returns(@client_applications)
30
+ do_get
31
+ end
32
+
33
+ def test_should_assign_client_applications
34
+ do_get
35
+ assert_equal @client_applications, assigns(:client_applications)
36
+ end
37
+
38
+ def test_should_render_index_template
39
+ do_get
40
+ assert_template 'index'
41
+ end
42
+ end
43
+
44
+ class OauthClientsControllerShowTest < ActionController::TestCase
45
+ include OAuthControllerTestHelper
46
+ tests OauthClientsController
47
+
48
+ def setup
49
+ @controller = OauthClientsController.new
50
+ @request = ActionController::TestRequest.new
51
+ @response = ActionController::TestResponse.new
52
+
53
+ login_as_application_owner
54
+ end
55
+
56
+ def do_get
57
+ get :show, :id => '3'
58
+ end
59
+
60
+ def test_should_be_successful
61
+ do_get
62
+ assert @response.success?
63
+ end
64
+
65
+ def test_should_query_current_users_client_applications
66
+ @user.expects(:client_applications).returns(@client_applications)
67
+ @client_applications.expects(:find).with('3').returns(@client_application)
68
+ do_get
69
+ end
70
+
71
+ def test_should_assign_client_applications
72
+ do_get
73
+ assert_equal @client_application, assigns(:client_application)
74
+ end
75
+
76
+ def test_should_render_show_template
77
+ do_get
78
+ assert_template 'show'
79
+ end
80
+
81
+ end
82
+
83
+ class OauthClientsControllerNewTest < ActionController::TestCase
84
+ include OAuthControllerTestHelper
85
+ tests OauthClientsController
86
+
87
+ def setup
88
+ @controller = OauthClientsController.new
89
+ @request = ActionController::TestRequest.new
90
+ @response = ActionController::TestResponse.new
91
+
92
+ login_as_application_owner
93
+ ClientApplication.stubs(:new).returns(@client_application)
94
+ end
95
+
96
+ def do_get
97
+ get :new
98
+ end
99
+
100
+ def test_should_be_successful
101
+ do_get
102
+ assert @response.success?
103
+ end
104
+
105
+ def test_should_assign_client_applications
106
+ do_get
107
+ assert_equal @client_application, assigns(:client_application)
108
+ end
109
+
110
+ def test_should_render_show_template
111
+ do_get
112
+ assert_template 'new'
113
+ end
114
+
115
+ end
116
+
117
+ class OauthClientsControllerEditTest < ActionController::TestCase
118
+ include OAuthControllerTestHelper
119
+ tests OauthClientsController
120
+
121
+ def setup
122
+ @controller = OauthClientsController.new
123
+ @request = ActionController::TestRequest.new
124
+ @response = ActionController::TestResponse.new
125
+
126
+ login_as_application_owner
127
+ end
128
+
129
+ def do_get
130
+ get :edit, :id=>'3'
131
+ end
132
+
133
+ def test_should_be_successful
134
+ do_get
135
+ assert @response.success?
136
+ end
137
+
138
+ def test_should_query_current_users_client_applications
139
+ @user.expects(:client_applications).returns(@client_applications)
140
+ @client_applications.expects(:find).with('3').returns(@client_application)
141
+ do_get
142
+ end
143
+
144
+ def test_should_assign_client_applications
145
+ do_get
146
+ assert_equal @client_application, assigns(:client_application)
147
+ end
148
+
149
+ def test_should_render_edit_template
150
+ do_get
151
+ assert_template 'edit'
152
+ end
153
+
154
+ end
155
+
156
+ class OauthClientsControllerCreateTest < ActionController::TestCase
157
+ include OAuthControllerTestHelper
158
+ tests OauthClientsController
159
+
160
+ def setup
161
+ @controller = OauthClientsController.new
162
+ @request = ActionController::TestRequest.new
163
+ @response = ActionController::TestResponse.new
164
+
165
+ login_as_application_owner
166
+ @client_applications.stubs(:build).returns(@client_application)
167
+ @client_application.stubs(:save).returns(true)
168
+ end
169
+
170
+ def do_valid_post
171
+ @client_application.expects(:save).returns(true)
172
+ post :create,'client_application' => {'name' => 'my site'}
173
+ end
174
+
175
+ def do_invalid_post
176
+ @client_application.expects(:save).returns(false)
177
+ post :create,:client_application=>{:name => 'my site'}
178
+ end
179
+
180
+ def test_should_query_current_users_client_applications
181
+ @client_applications.expects(:build).returns(@client_application)
182
+ do_valid_post
183
+ end
184
+
185
+ def test_should_redirect_to_new_client_application
186
+ do_valid_post
187
+ assert_response :redirect
188
+ assert_redirected_to(:action => "show", :id => @client_application.id)
189
+ end
190
+
191
+ def test_should_assign_client_applications
192
+ do_invalid_post
193
+ assert_equal @client_application, assigns(:client_application)
194
+ end
195
+
196
+ def test_should_render_show_template
197
+ do_invalid_post
198
+ assert_template('new')
199
+ end
200
+ end
201
+
202
+ class OauthClientsControllerDestroyTest < ActionController::TestCase
203
+ include OAuthControllerTestHelper
204
+ tests OauthClientsController
205
+
206
+ def setup
207
+ @controller = OauthClientsController.new
208
+ @request = ActionController::TestRequest.new
209
+ @response = ActionController::TestResponse.new
210
+
211
+ login_as_application_owner
212
+ @client_application.stubs(:destroy)
213
+ end
214
+
215
+ def do_delete
216
+ delete :destroy,:id=>'3'
217
+ end
218
+
219
+ def test_should_query_current_users_client_applications
220
+ @user.expects(:client_applications).returns(@client_applications)
221
+ @client_applications.expects(:find).with('3').returns(@client_application)
222
+ do_delete
223
+ end
224
+
225
+ def test_should_destroy_client_applications
226
+ @client_application.expects(:destroy)
227
+ do_delete
228
+ end
229
+
230
+ def test_should_redirect_to_list
231
+ do_delete
232
+ assert_response :redirect
233
+ assert_redirected_to :action => 'index'
234
+ end
235
+
236
+ end
237
+
238
+ class OauthClientsControllerUpdateTest < ActionController::TestCase
239
+ include OAuthControllerTestHelper
240
+ tests OauthClientsController
241
+
242
+ def setup
243
+ @controller = OauthClientsController.new
244
+ @request = ActionController::TestRequest.new
245
+ @response = ActionController::TestResponse.new
246
+ login_as_application_owner
247
+ end
248
+
249
+ def do_valid_update
250
+ @client_application.expects(:update_attributes).returns(true)
251
+ put :update, :id => '1', 'client_application' => {'name' => 'my site'}
252
+ end
253
+
254
+ def do_invalid_update
255
+ @client_application.expects(:update_attributes).returns(false)
256
+ put :update, :id=>'1', 'client_application' => {'name' => 'my site'}
257
+ end
258
+
259
+ def test_should_query_current_users_client_applications
260
+ @user.expects(:client_applications).returns(@client_applications)
261
+ @client_applications.expects(:find).with('1').returns(@client_application)
262
+ do_valid_update
263
+ end
264
+
265
+ def test_should_redirect_to_new_client_application
266
+ do_valid_update
267
+ assert_response :redirect
268
+ assert_redirected_to :action => "show", :id => @client_application.id
269
+ end
270
+
271
+ def test_should_assign_client_applications
272
+ do_invalid_update
273
+ assert_equal @client_application, assigns(:client_application)
274
+ end
275
+
276
+ def test_should_render_show_template
277
+ do_invalid_update
278
+ assert_template('edit')
279
+ end
280
+ end
@@ -0,0 +1,23 @@
1
+ require 'oauth/controllers/provider_controller'
2
+ class OauthController < ApplicationController
3
+ include OAuth::Controllers::ProviderController
4
+
5
+ protected
6
+ # Override this to match your authorization page form
7
+ # It currently expects a checkbox called authorize
8
+ # def user_authorizes_token?
9
+ # params[:authorize] == '1'
10
+ # end
11
+
12
+ # should authenticate and return a user if valid password.
13
+ # This example should work with most Authlogic or Devise. Uncomment it
14
+ # def authenticate_user(username,password)
15
+ # user = User.find_by_email params[:username]
16
+ # if user && user.valid_password?(params[:password])
17
+ # user
18
+ # else
19
+ # nil
20
+ # end
21
+ # end
22
+
23
+ end
@@ -0,0 +1,7 @@
1
+ <h1>Edit your application</h1>
2
+ <%% form_for :client_application, @client_application, :url => oauth_client_path(@client_application), :html => {:method => :put} do |f| %>
3
+ <%%= render :partial => "form", :locals => { :f => f } %>
4
+ <%%= submit_tag "Edit" %>
5
+ <%% end %>
6
+ <%%= link_to 'Show', oauth_client_path(@client_application) %> |
7
+ <%%= link_to 'Back', oauth_clients_path %>
@@ -0,0 +1,4 @@
1
+ %h1 Edit your application
2
+ - form_for :client_application do |f|
3
+ = render :partial => "form", :locals => { :f => f }
4
+ = submit_tag "Edit"
@@ -0,0 +1,43 @@
1
+ <div class="flash"><%%= flash[:notice] %></div>
2
+ <h1>OAuth Client Applications</h1>
3
+ <%% unless @tokens.empty? %>
4
+ <p>The following tokens have been issued to applications in your name</p>
5
+ <table>
6
+ <tr><th>Application</th><th>Issued</th><th>&nbsp;</th></tr>
7
+ <%% @tokens.each do |token|%>
8
+ <%% content_tag_for :tr, token do %>
9
+ <td><%%= link_to token.client_application.name, token.client_application.url %></td>
10
+ <td><%%= token.authorized_at %></td>
11
+ <td>
12
+ <%% form_tag :controller => 'oauth', :action => 'revoke' do %>
13
+ <%%= hidden_field_tag 'token', token.token %>
14
+ <%%= submit_tag "Revoke!" %>
15
+ <%% end %>
16
+ </td>
17
+ <%% end %>
18
+ <%% end %>
19
+
20
+ </table>
21
+ <%% end %>
22
+ <h3>Application Developers</h3>
23
+ <%% if @client_applications.empty? %>
24
+ <p>
25
+ Do you have an application you would like to register for use with us using the <a href="http://oauth.net">OAuth</a> standard?
26
+ </p>
27
+ <p>
28
+ You must register your web application before it can make OAuth requests to this service
29
+ </p>
30
+ <%% else %>
31
+ <p>
32
+ You have the following client applications registered:
33
+ </p>
34
+ <%% @client_applications.each do |client|%>
35
+ <%% div_for client do %>
36
+ <%%= link_to client.name, oauth_client_path(client) %>-
37
+ <%%= link_to 'Edit', edit_oauth_client_path(client) %>
38
+ <%%= link_to 'Delete', oauth_client_path(client), :confirm => "Are you sure?", :method => :delete %>
39
+ <%% end %>
40
+ <%% end %>
41
+ <%% end %>
42
+ <br />
43
+ <h3><%%= link_to "Register your application", :action => :new %></h3>
@@ -0,0 +1,39 @@
1
+ .flash= flash[:notice]
2
+ %h1 OAuth Client Applications
3
+ - unless @tokens.empty?
4
+
5
+ %p
6
+ The following tokens have been issued to applications in your name
7
+
8
+ %table
9
+ %tr
10
+ %th Application
11
+ %th Issued
12
+ %th &nbsp;
13
+ - @tokens.each do |token|
14
+ - content_tag_for :tr, token do
15
+ %td= link_to token.client_application.name, token.client_application.url
16
+ %td= token.authorized_at
17
+ %td
18
+ - form_tag :controller => 'oauth', :action => 'revoke' do
19
+ = hidden_field_tag 'token', token.token
20
+ = submit_tag "Revoke!"
21
+
22
+ %h3 Application Developers
23
+
24
+ - if @client_applications.empty?
25
+ %p
26
+ Do you have an application you would like to register for use with us using the <a href="http://oauth.net">OAuth</a> standard?
27
+ You must register your web application before it can make OAuth requests to this service
28
+ - else
29
+ %p
30
+ You have the following client applications registered:
31
+
32
+ - @client_applications.each do |client|
33
+ - div_for client do
34
+ = link_to client.name, :action => :show, :id => client.id
35
+ = link_to 'Edit', edit_oauth_client_path(client)
36
+ = link_to 'Delete', oauth_client_path(client), :confirm => "Are you sure?", :method => :delete
37
+ %br
38
+ %h3
39
+ = link_to "Register your application", :action => :new
@@ -0,0 +1,47 @@
1
+ class CreateOauthTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :client_applications do |t|
4
+ t.string :name
5
+ t.string :url
6
+ t.string :support_url
7
+ t.string :callback_url
8
+ t.string :key, :limit => 40
9
+ t.string :secret, :limit => 40
10
+ t.integer :user_id
11
+
12
+ t.timestamps
13
+ end
14
+ add_index :client_applications, :key, :unique => true
15
+
16
+ create_table :oauth_tokens do |t|
17
+ t.integer :user_id
18
+ t.string :type, :limit => 20
19
+ t.integer :client_application_id
20
+ t.string :token, :limit => 40
21
+ t.string :secret, :limit => 40
22
+ t.string :callback_url
23
+ t.string :verifier, :limit => 20
24
+ t.string :scope
25
+ t.timestamp :authorized_at, :invalidated_at, :expires_at
26
+ t.timestamps
27
+ end
28
+
29
+ add_index :oauth_tokens, :token, :unique => true
30
+
31
+ create_table :oauth_nonces do |t|
32
+ t.string :nonce
33
+ t.integer :timestamp
34
+
35
+ t.timestamps
36
+ end
37
+ add_index :oauth_nonces,[:nonce, :timestamp], :unique
38
+
39
+ end
40
+
41
+ def self.down
42
+ drop_table :client_applications
43
+ drop_table :oauth_tokens
44
+ drop_table :oauth_nonces
45
+ end
46
+
47
+ end