houston-oauth-plugin 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/CHANGELOG +187 -0
  4. data/Gemfile +27 -0
  5. data/Guardfile +8 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +542 -0
  8. data/Rakefile +1 -0
  9. data/UPGRADE.rdoc +21 -0
  10. data/generators/oauth_consumer/USAGE +10 -0
  11. data/generators/oauth_consumer/oauth_consumer_generator.rb +52 -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/index.html.slim +15 -0
  17. data/generators/oauth_consumer/templates/migration.rb +23 -0
  18. data/generators/oauth_consumer/templates/oauth_config.rb +73 -0
  19. data/generators/oauth_consumer/templates/show.html.erb +7 -0
  20. data/generators/oauth_consumer/templates/show.html.haml +8 -0
  21. data/generators/oauth_consumer/templates/show.html.slim +8 -0
  22. data/generators/oauth_provider/USAGE +20 -0
  23. data/generators/oauth_provider/lib/insert_routes.rb +67 -0
  24. data/generators/oauth_provider/oauth_provider_generator.rb +127 -0
  25. data/generators/oauth_provider/templates/_form.html.erb +17 -0
  26. data/generators/oauth_provider/templates/_form.html.haml +21 -0
  27. data/generators/oauth_provider/templates/access_token.rb +16 -0
  28. data/generators/oauth_provider/templates/authorize.html.erb +14 -0
  29. data/generators/oauth_provider/templates/authorize.html.haml +16 -0
  30. data/generators/oauth_provider/templates/authorize_failure.html.erb +1 -0
  31. data/generators/oauth_provider/templates/authorize_failure.html.haml +1 -0
  32. data/generators/oauth_provider/templates/authorize_success.html.erb +1 -0
  33. data/generators/oauth_provider/templates/authorize_success.html.haml +1 -0
  34. data/generators/oauth_provider/templates/client_application.rb +57 -0
  35. data/generators/oauth_provider/templates/client_application_spec.rb +29 -0
  36. data/generators/oauth_provider/templates/client_application_test.rb +42 -0
  37. data/generators/oauth_provider/templates/client_applications.yml +23 -0
  38. data/generators/oauth_provider/templates/clients_controller.rb +52 -0
  39. data/generators/oauth_provider/templates/clients_controller_spec.rb +176 -0
  40. data/generators/oauth_provider/templates/clients_controller_test.rb +280 -0
  41. data/generators/oauth_provider/templates/controller.rb +23 -0
  42. data/generators/oauth_provider/templates/edit.html.erb +7 -0
  43. data/generators/oauth_provider/templates/edit.html.haml +4 -0
  44. data/generators/oauth_provider/templates/index.html.erb +43 -0
  45. data/generators/oauth_provider/templates/index.html.haml +39 -0
  46. data/generators/oauth_provider/templates/migration.rb +47 -0
  47. data/generators/oauth_provider/templates/new.html.erb +5 -0
  48. data/generators/oauth_provider/templates/new.html.haml +5 -0
  49. data/generators/oauth_provider/templates/oauth2_authorize.html.erb +16 -0
  50. data/generators/oauth_provider/templates/oauth2_authorize.html.haml +17 -0
  51. data/generators/oauth_provider/templates/oauth2_token.rb +20 -0
  52. data/generators/oauth_provider/templates/oauth2_token_spec.rb +52 -0
  53. data/generators/oauth_provider/templates/oauth2_verifier.rb +35 -0
  54. data/generators/oauth_provider/templates/oauth2_verifier_spec.rb +44 -0
  55. data/generators/oauth_provider/templates/oauth_nonce.rb +13 -0
  56. data/generators/oauth_provider/templates/oauth_nonce_spec.rb +24 -0
  57. data/generators/oauth_provider/templates/oauth_nonce_test.rb +26 -0
  58. data/generators/oauth_provider/templates/oauth_nonces.yml +13 -0
  59. data/generators/oauth_provider/templates/oauth_token.rb +30 -0
  60. data/generators/oauth_provider/templates/oauth_token_spec.rb +309 -0
  61. data/generators/oauth_provider/templates/oauth_token_test.rb +57 -0
  62. data/generators/oauth_provider/templates/oauth_tokens.yml +17 -0
  63. data/generators/oauth_provider/templates/request_token.rb +40 -0
  64. data/generators/oauth_provider/templates/show.html.erb +27 -0
  65. data/generators/oauth_provider/templates/show.html.haml +30 -0
  66. data/init.rb +1 -0
  67. data/install.rb +2 -0
  68. data/lib/generators/active_record/oauth_consumer_generator.rb +33 -0
  69. data/lib/generators/active_record/oauth_consumer_templates/consumer_token.rb +11 -0
  70. data/lib/generators/active_record/oauth_consumer_templates/migration.rb +20 -0
  71. data/lib/generators/active_record/oauth_provider_generator.rb +39 -0
  72. data/lib/generators/active_record/oauth_provider_templates/access_token.rb +16 -0
  73. data/lib/generators/active_record/oauth_provider_templates/client_application.rb +57 -0
  74. data/lib/generators/active_record/oauth_provider_templates/migration.rb +47 -0
  75. data/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb +20 -0
  76. data/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb +35 -0
  77. data/lib/generators/active_record/oauth_provider_templates/oauth_nonce.rb +13 -0
  78. data/lib/generators/active_record/oauth_provider_templates/oauth_token.rb +30 -0
  79. data/lib/generators/active_record/oauth_provider_templates/request_token.rb +40 -0
  80. data/lib/generators/erb/oauth_consumer_generator.rb +14 -0
  81. data/lib/generators/erb/oauth_consumer_templates/index.html.erb +29 -0
  82. data/lib/generators/erb/oauth_consumer_templates/show.html.erb +7 -0
  83. data/lib/generators/erb/oauth_provider_generator.rb +23 -0
  84. data/lib/generators/erb/oauth_provider_templates/_form.html.erb +17 -0
  85. data/lib/generators/erb/oauth_provider_templates/authorize.html.erb +14 -0
  86. data/lib/generators/erb/oauth_provider_templates/authorize_failure.html.erb +1 -0
  87. data/lib/generators/erb/oauth_provider_templates/authorize_success.html.erb +1 -0
  88. data/lib/generators/erb/oauth_provider_templates/edit.html.erb +7 -0
  89. data/lib/generators/erb/oauth_provider_templates/index.html.erb +43 -0
  90. data/lib/generators/erb/oauth_provider_templates/new.html.erb +5 -0
  91. data/lib/generators/erb/oauth_provider_templates/oauth2_authorize.html.erb +16 -0
  92. data/lib/generators/erb/oauth_provider_templates/show.html.erb +27 -0
  93. data/lib/generators/haml/oauth_consumer_generator.rb +21 -0
  94. data/lib/generators/haml/oauth_consumer_templates/index.html.haml +18 -0
  95. data/lib/generators/haml/oauth_consumer_templates/show.html.haml +8 -0
  96. data/lib/generators/haml/oauth_provider_generator.rb +28 -0
  97. data/lib/generators/haml/oauth_provider_templates/_form.html.haml +21 -0
  98. data/lib/generators/haml/oauth_provider_templates/authorize.html.haml +16 -0
  99. data/lib/generators/haml/oauth_provider_templates/authorize_failure.html.haml +1 -0
  100. data/lib/generators/haml/oauth_provider_templates/authorize_success.html.haml +1 -0
  101. data/lib/generators/haml/oauth_provider_templates/edit.html.haml +4 -0
  102. data/lib/generators/haml/oauth_provider_templates/index.html.haml +39 -0
  103. data/lib/generators/haml/oauth_provider_templates/new.html.haml +5 -0
  104. data/lib/generators/haml/oauth_provider_templates/oauth2_authorize.html.haml +17 -0
  105. data/lib/generators/haml/oauth_provider_templates/show.html.haml +30 -0
  106. data/lib/generators/mongoid/oauth_consumer_generator.rb +15 -0
  107. data/lib/generators/mongoid/oauth_consumer_templates/consumer_token.rb +41 -0
  108. data/lib/generators/mongoid/oauth_provider_generator.rb +21 -0
  109. data/lib/generators/mongoid/oauth_provider_templates/access_token.rb +16 -0
  110. data/lib/generators/mongoid/oauth_provider_templates/client_application.rb +71 -0
  111. data/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb +20 -0
  112. data/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb +35 -0
  113. data/lib/generators/mongoid/oauth_provider_templates/oauth_nonce.rb +24 -0
  114. data/lib/generators/mongoid/oauth_provider_templates/oauth_token.rb +44 -0
  115. data/lib/generators/mongoid/oauth_provider_templates/request_token.rb +36 -0
  116. data/lib/generators/oauth_consumer/USAGE +11 -0
  117. data/lib/generators/oauth_consumer/oauth_consumer_generator.rb +31 -0
  118. data/lib/generators/oauth_consumer/templates/controller.rb +59 -0
  119. data/lib/generators/oauth_consumer/templates/oauth_config.rb +68 -0
  120. data/lib/generators/oauth_inflections.rb +6 -0
  121. data/lib/generators/oauth_plugin.rb +0 -0
  122. data/lib/generators/oauth_provider/USAGE +18 -0
  123. data/lib/generators/oauth_provider/oauth_provider_generator.rb +37 -0
  124. data/lib/generators/oauth_provider/templates/clients_controller.rb +52 -0
  125. data/lib/generators/oauth_provider/templates/controller.rb +23 -0
  126. data/lib/generators/rspec/oauth_provider_generator.rb +35 -0
  127. data/lib/generators/rspec/templates/client_application_spec.rb +29 -0
  128. data/lib/generators/rspec/templates/client_applications.yml +23 -0
  129. data/lib/generators/rspec/templates/clients_controller_spec.rb +176 -0
  130. data/lib/generators/rspec/templates/oauth2_token_spec.rb +52 -0
  131. data/lib/generators/rspec/templates/oauth2_verifier_spec.rb +44 -0
  132. data/lib/generators/rspec/templates/oauth_nonce_spec.rb +24 -0
  133. data/lib/generators/rspec/templates/oauth_nonces.yml +13 -0
  134. data/lib/generators/rspec/templates/oauth_token_spec.rb +309 -0
  135. data/lib/generators/rspec/templates/oauth_tokens.yml +17 -0
  136. data/lib/generators/slim/oauth_consumer_generator.rb +21 -0
  137. data/lib/generators/slim/oauth_consumer_templates/index.html.slim +15 -0
  138. data/lib/generators/slim/oauth_consumer_templates/show.html.slim +8 -0
  139. data/lib/generators/test_unit/oauth_provider_generator.rb +33 -0
  140. data/lib/generators/test_unit/templates/client_application_test.rb +42 -0
  141. data/lib/generators/test_unit/templates/client_applications.yml +23 -0
  142. data/lib/generators/test_unit/templates/clients_controller_test.rb +280 -0
  143. data/lib/generators/test_unit/templates/oauth_nonce_test.rb +26 -0
  144. data/lib/generators/test_unit/templates/oauth_nonces.yml +13 -0
  145. data/lib/generators/test_unit/templates/oauth_token_test.rb +57 -0
  146. data/lib/generators/test_unit/templates/oauth_tokens.yml +17 -0
  147. data/lib/oauth-plugin.rb +24 -0
  148. data/lib/oauth-plugin/version.rb +5 -0
  149. data/lib/oauth/controllers/application_controller_methods.rb +140 -0
  150. data/lib/oauth/controllers/consumer_controller.rb +153 -0
  151. data/lib/oauth/controllers/provider_controller.rb +181 -0
  152. data/lib/oauth/models/consumers/service_loader.rb +28 -0
  153. data/lib/oauth/models/consumers/services/agree2_token.rb +15 -0
  154. data/lib/oauth/models/consumers/services/fireeagle_token.rb +39 -0
  155. data/lib/oauth/models/consumers/services/google_token.rb +21 -0
  156. data/lib/oauth/models/consumers/services/oauth2_token.rb +49 -0
  157. data/lib/oauth/models/consumers/services/opentransact_token.rb +15 -0
  158. data/lib/oauth/models/consumers/services/picomoney_token.rb +17 -0
  159. data/lib/oauth/models/consumers/services/twitter_token.rb +24 -0
  160. data/lib/oauth/models/consumers/simple_client.rb +50 -0
  161. data/lib/oauth/models/consumers/token.rb +121 -0
  162. data/lib/oauth/provider/authorizer.rb +83 -0
  163. data/lib/oauth/rack/oauth_filter.rb +97 -0
  164. data/oauth-plugin.gemspec +40 -0
  165. data/rails/init.rb +1 -0
  166. data/spec/dummy_provider_models.rb +53 -0
  167. data/spec/oauth/provider/authorizer_spec.rb +202 -0
  168. data/spec/rack/oauth_filter_spec.rb +244 -0
  169. data/spec/spec_helper.rb +3 -0
  170. data/tasks/oauth_tasks.rake +4 -0
  171. data/uninstall.rb +1 -0
  172. metadata +373 -0
@@ -0,0 +1,13 @@
1
+ # Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
2
+ # Thus you can use the same nonce with a different timestamp and viceversa.
3
+ class OauthNonce < ActiveRecord::Base
4
+ validates_presence_of :nonce, :timestamp
5
+ validates_uniqueness_of :nonce, :scope => :timestamp
6
+
7
+ # Remembers a nonce and it's associated timestamp. It returns false if it has already been used
8
+ def self.remember(nonce, timestamp)
9
+ oauth_nonce = OauthNonce.create(:nonce => nonce, :timestamp => timestamp)
10
+ return false if oauth_nonce.new_record?
11
+ oauth_nonce
12
+ end
13
+ end
@@ -0,0 +1,30 @@
1
+ class OauthToken < ActiveRecord::Base
2
+ belongs_to :client_application
3
+ belongs_to :user
4
+ validates_uniqueness_of :token
5
+ validates_presence_of :client_application, :token
6
+ before_validation :generate_keys, :on => :create
7
+
8
+ def invalidated?
9
+ invalidated_at != nil
10
+ end
11
+
12
+ def invalidate!
13
+ update_attribute(:invalidated_at, Time.now)
14
+ end
15
+
16
+ def authorized?
17
+ authorized_at != nil && !invalidated?
18
+ end
19
+
20
+ def to_query
21
+ "oauth_token=#{token}&oauth_token_secret=#{secret}"
22
+ end
23
+
24
+ protected
25
+
26
+ def generate_keys
27
+ self.token = OAuth::Helper.generate_key(40)[0,40]
28
+ self.secret = OAuth::Helper.generate_key(40)[0,40]
29
+ end
30
+ end
@@ -0,0 +1,40 @@
1
+ class RequestToken < OauthToken
2
+
3
+ attr_accessor :provided_oauth_verifier
4
+
5
+ def authorize!(user)
6
+ return false if authorized?
7
+ self.user = user
8
+ self.authorized_at = Time.now
9
+ self.verifier=OAuth::Helper.generate_key(20)[0,20] unless oauth10?
10
+ self.save
11
+ end
12
+
13
+ def exchange!
14
+ return false unless authorized?
15
+ return false unless oauth10? || verifier==provided_oauth_verifier
16
+
17
+ RequestToken.transaction do
18
+ access_token = AccessToken.create(:user => user, :client_application => client_application)
19
+ invalidate!
20
+ access_token
21
+ end
22
+ end
23
+
24
+ def to_query
25
+ if oauth10?
26
+ super
27
+ else
28
+ "#{super}&oauth_callback_confirmed=true"
29
+ end
30
+ end
31
+
32
+ def oob?
33
+ callback_url.nil? || callback_url.downcase == 'oob'
34
+ end
35
+
36
+ def oauth10?
37
+ (defined? OAUTH_10_SUPPORT) && OAUTH_10_SUPPORT && self.callback_url.blank?
38
+ end
39
+
40
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails/generators/erb'
2
+
3
+ module Erb
4
+ module Generators
5
+ class OauthConsumerGenerator < Erb::Generators::Base
6
+ source_root File.expand_path('../oauth_consumer_templates', __FILE__)
7
+
8
+ def copy_view_files
9
+ template 'index.html.erb', File.join('app/views', class_path, 'oauth_consumers', 'index.html.erb')
10
+ template 'show.html.erb', File.join('app/views', class_path, 'oauth_consumers', 'show.html.erb')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ <h1>Services</h1>
2
+
3
+ <%% if @consumer_tokens.empty? %>
4
+ <p>
5
+ You are currently not connected to any external services.
6
+ </p>
7
+ <%% else %>
8
+ <p>
9
+ You are connected to the following services:
10
+ </p>
11
+ <ul>
12
+ <%% @consumer_tokens.each do |token| %>
13
+ <li>
14
+ <%%= link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name) %>
15
+ </li>
16
+ <%% end %>
17
+ </ul>
18
+ <%% end %>
19
+
20
+ <%% unless @services.empty? %>
21
+ <h3>You can connect to the following services:</h3>
22
+ <ul>
23
+ <%% @services.each do |service| %>
24
+ <li>
25
+ <%%= link_to service.to_s.humanize, oauth_consumer_path(service) %>
26
+ </li>
27
+ <%% end %>
28
+ </ul>
29
+ <%% end %>
@@ -0,0 +1,7 @@
1
+ <h1>You are already Connected to <%%=params[:id].humanize%></h1>
2
+ <%% form_tag oauth_consumer_path(params[:id]),:method=>:delete do %>
3
+ <%%=submit_tag "Disconnect" %>
4
+ or
5
+ <%%=submit_tag "Reconnect" %>
6
+ if you experienced a problem.
7
+ <%% end %>
@@ -0,0 +1,23 @@
1
+ require 'rails/generators/erb'
2
+
3
+ module Erb
4
+ module Generators
5
+ class OauthProviderGenerator < Erb::Generators::Base
6
+ source_root File.expand_path('../oauth_provider_templates', __FILE__)
7
+
8
+ argument :name, :type => :string, :default => 'Oauth'
9
+
10
+ def copy_view_files
11
+ template '_form.html.erb', File.join('app/views', class_path, 'oauth_clients', '_form.html.erb')
12
+ template 'new.html.erb', File.join('app/views', class_path, 'oauth_clients', 'new.html.erb')
13
+ template 'index.html.erb', File.join('app/views', class_path, 'oauth_clients', 'index.html.erb')
14
+ template 'show.html.erb', File.join('app/views', class_path, 'oauth_clients', 'show.html.erb')
15
+ template 'edit.html.erb', File.join('app/views', class_path, 'oauth_clients', 'edit.html.erb')
16
+ template 'authorize.html.erb', File.join('app/views', class_path, file_name, 'authorize.html.erb')
17
+ template 'oauth2_authorize.html.erb', File.join('app/views', class_path, file_name, 'oauth2_authorize.html.erb')
18
+ template 'authorize_success.html.erb', File.join('app/views', class_path, file_name, 'authorize_success.html.erb')
19
+ template 'authorize_failure.html.erb', File.join('app/views', class_path, file_name, 'authorize_failure.html.erb')
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ <%%= error_messages_for :client_application %>
2
+ <div class="field">
3
+ <label for="client_application_name">Name*</label><br/>
4
+ <%%= f.text_field :name %>
5
+ </div>
6
+ <div class="field">
7
+ <label for="client_application_url">Main Application URL*</label><br/>
8
+ <%%= f.text_field :url %>
9
+ </div>
10
+ <div class="field">
11
+ <label for="client_application_callback_url">Callback URL*</label><br/>
12
+ <%%= f.text_field :callback_url %>
13
+ </div>
14
+ <div class="field">
15
+ <label for="client_application_support_url">Support URL</label><br/>
16
+ <%%= f.text_field :support_url %>
17
+ </div>
@@ -0,0 +1,14 @@
1
+ <h1>Authorize access to your account</h1>
2
+ <p>Would you like to authorize <%%= link_to @token.client_application.name,@token.client_application.url %> (<%%= link_to @token.client_application.url,@token.client_application.url %>) to access your account?</p>
3
+ <%%= form_tag authorize_url do %>
4
+ <%%= hidden_field_tag "oauth_token", @token.token %>
5
+ <%%- if params[:oauth_callback] -%>
6
+ <%%= hidden_field_tag "oauth_callback", params[:oauth_callback] %>
7
+ <%%- end -%>
8
+ <p>
9
+ <%%= check_box_tag 'authorize' %> authorize access
10
+ </p>
11
+ <p>
12
+ <%%= submit_tag %>
13
+ </p>
14
+ <%% end %>
@@ -0,0 +1 @@
1
+ <h1>You have disallowed this request</h1>
@@ -0,0 +1 @@
1
+ <h1>You have allowed this request</h1>
@@ -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,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,5 @@
1
+ <h1>Register a new application</h1>
2
+ <%%= form_for :client_application, :url => { :action => :create } do |f| %>
3
+ <%%= render :partial => "form", :locals => { :f => f } %>
4
+ <%%= submit_tag "Register" %>
5
+ <%% end %>
@@ -0,0 +1,16 @@
1
+ <h1>Authorize access to your account</h1>
2
+ <p>Would you like to authorize <%%= link_to @token.client_application.name,@token.client_application.url %> (<%%= link_to @token.client_application.url,@token.client_application.url %>) to access your account?</p>
3
+ <%%= form_tag authorize_url do %>
4
+ <%%= hidden_field_tag "response_type", params[:response_type]%>
5
+ <%%= hidden_field_tag "client_id", params[:client_id]%>
6
+ <%%= hidden_field_tag "redirect_uri", params[:redirect_uri]%>
7
+ <%%= hidden_field_tag "state", params[:state]%>
8
+ <%%= hidden_field_tag "scope", params[:scope]%>
9
+
10
+ <p>
11
+ <%%= check_box_tag 'authorize' %> authorize access
12
+ </p>
13
+ <p>
14
+ <%%= submit_tag %>
15
+ </p>
16
+ <%% end %>
@@ -0,0 +1,27 @@
1
+ <h1>OAuth details for <%%=@client_application.name %></h1>
2
+ <p>
3
+ <strong>Consumer Key:</strong>
4
+ <code><%%=@client_application.key %></code>
5
+ </p>
6
+ <p>
7
+ <strong>Consumer Secret:</strong>
8
+ <code><%%=@client_application.secret %></code>
9
+ </p>
10
+ <p>
11
+ <strong>Request Token URL</strong>
12
+ <code>http<%%='s' if request.ssl? %>://<%%= request.host_with_port %><%%=@client_application.oauth_server.request_token_path %></code>
13
+ </p>
14
+ <p>
15
+ <strong>Access Token URL</strong>
16
+ <code>http<%%='s' if request.ssl? %>://<%%= request.host_with_port %><%%=@client_application.oauth_server.access_token_path %></code>
17
+ </p>
18
+ <p>
19
+ <strong>Authorize URL</strong>
20
+ <code>http<%%='s' if request.ssl? %>://<%%= request.host_with_port %><%%=@client_application.oauth_server.authorize_path %></code>
21
+ </p>
22
+
23
+ <p>
24
+ We support hmac-sha1 (recommended) as well as plain text in ssl mode.
25
+ </p>
26
+ <%%= link_to 'Edit', edit_oauth_client_path(@client_application) %> |
27
+ <%%= link_to 'Back', oauth_clients_path %>
@@ -0,0 +1,21 @@
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+
3
+ module Haml
4
+ module Generators
5
+ class OauthConsumerGenerator < Erb::Generators::Base
6
+ source_root File.expand_path('../oauth_consumer_templates', __FILE__)
7
+
8
+ argument :name, :type => :string, :default => 'Oauth'
9
+
10
+ def copy_view_files
11
+ template 'index.html.haml', File.join('app/views', class_path, 'oauth_consumers', 'index.html.haml')
12
+ template 'show.html.haml', File.join('app/views', class_path, 'oauth_consumers', 'show.html.haml')
13
+ end
14
+
15
+ protected
16
+ def handler
17
+ :haml
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ %h1 Services
2
+
3
+ -if @consumer_tokens.empty?
4
+ %p
5
+ You are currently not connected to any external services.
6
+ -else
7
+ %p You are connected to the following services:
8
+ %ul
9
+ -@consumer_tokens.each do |token|
10
+ %li
11
+ =link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name)
12
+
13
+ -unless @services.empty?
14
+ %h3 You can connect to the following services:
15
+ %ul
16
+ -@services.each do |service|
17
+ %li
18
+ =link_to service.to_s.humanize,oauth_consumer_path(service)
@@ -0,0 +1,8 @@
1
+ %h1
2
+ You are already Connected to
3
+ =params[:id].humanize
4
+ -form_tag oauth_consumer_path(params[:id]),:method=>:delete do
5
+ =submit_tag "Disconnect"
6
+ or
7
+ =submit_tag "Reconnect"
8
+ if you experienced a problem.
@@ -0,0 +1,28 @@
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+
3
+ module Haml
4
+ module Generators
5
+ class OauthProviderGenerator < Erb::Generators::Base
6
+ source_root File.expand_path('../oauth_provider_templates', __FILE__)
7
+
8
+ argument :name, :type => :string, :default => 'Oauth'
9
+
10
+ def copy_view_files
11
+ template '_form.html.haml', File.join('app/views', class_path, 'oauth_clients', '_form.html.haml')
12
+ template 'new.html.haml', File.join('app/views', class_path, 'oauth_clients', 'new.html.haml')
13
+ template 'index.html.haml', File.join('app/views', class_path, 'oauth_clients', 'index.html.haml')
14
+ template 'show.html.haml', File.join('app/views', class_path, 'oauth_clients', 'show.html.haml')
15
+ template 'edit.html.haml', File.join('app/views', class_path, 'oauth_clients', 'edit.html.haml')
16
+ template 'authorize.html.haml', File.join('app/views', class_path, file_name, 'authorize.html.haml')
17
+ template 'oauth2_authorize.html.haml', File.join('app/views', class_path, file_name, 'oauth2_authorize.html.haml')
18
+ template 'authorize_success.html.haml', File.join('app/views', class_path, file_name, 'authorize_success.html.haml')
19
+ template 'authorize_failure.html.haml', File.join('app/views', class_path, file_name, 'authorize_failure.html.haml')
20
+ end
21
+
22
+ protected
23
+ def handler
24
+ :haml
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ =error_messages_for :client_application
2
+ .field
3
+ %label{:for=>"client_application_name"} Name*
4
+ %br
5
+ = f.text_field :name
6
+
7
+ .field
8
+ %label{:for=>"client_application_url"} Main Application URL*
9
+ %br
10
+ = f.text_field :url
11
+
12
+ .field
13
+ %label{:for=>"client_application_callback_url"} Callback URL*
14
+ %br
15
+ = f.text_field :callback_url
16
+
17
+ .field
18
+ %label{:for=>"client_application_support_url"} Support URL
19
+ %br
20
+ = f.text_field :support_url
21
+
@@ -0,0 +1,16 @@
1
+ %h1 Authorize access to your account
2
+ %p
3
+ Would you like to authorize
4
+ = link_to @token.client_application.name,@token.client_application.url
5
+ (
6
+ = link_to @token.client_application.url,@token.client_application.url
7
+ ) to access your account?
8
+ = form_tag authorize_url do
9
+ = hidden_field_tag "oauth_token", @token.token
10
+ - if params[:oauth_callback]
11
+ = hidden_field_tag "oauth_callback", params[:oauth_callback]
12
+ %p
13
+ = check_box_tag 'authorize'
14
+ authorize access
15
+ %p
16
+ = submit_tag
@@ -0,0 +1 @@
1
+ %h1 You have disallowed this request