houston-oauth-plugin 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/CHANGELOG +187 -0
- data/Gemfile +27 -0
- data/Guardfile +8 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +542 -0
- data/Rakefile +1 -0
- data/UPGRADE.rdoc +21 -0
- data/generators/oauth_consumer/USAGE +10 -0
- data/generators/oauth_consumer/oauth_consumer_generator.rb +52 -0
- data/generators/oauth_consumer/templates/consumer_token.rb +11 -0
- data/generators/oauth_consumer/templates/controller.rb +27 -0
- data/generators/oauth_consumer/templates/index.html.erb +29 -0
- data/generators/oauth_consumer/templates/index.html.haml +18 -0
- data/generators/oauth_consumer/templates/index.html.slim +15 -0
- data/generators/oauth_consumer/templates/migration.rb +23 -0
- data/generators/oauth_consumer/templates/oauth_config.rb +73 -0
- data/generators/oauth_consumer/templates/show.html.erb +7 -0
- data/generators/oauth_consumer/templates/show.html.haml +8 -0
- data/generators/oauth_consumer/templates/show.html.slim +8 -0
- data/generators/oauth_provider/USAGE +20 -0
- data/generators/oauth_provider/lib/insert_routes.rb +67 -0
- data/generators/oauth_provider/oauth_provider_generator.rb +127 -0
- data/generators/oauth_provider/templates/_form.html.erb +17 -0
- data/generators/oauth_provider/templates/_form.html.haml +21 -0
- data/generators/oauth_provider/templates/access_token.rb +16 -0
- data/generators/oauth_provider/templates/authorize.html.erb +14 -0
- data/generators/oauth_provider/templates/authorize.html.haml +16 -0
- data/generators/oauth_provider/templates/authorize_failure.html.erb +1 -0
- data/generators/oauth_provider/templates/authorize_failure.html.haml +1 -0
- data/generators/oauth_provider/templates/authorize_success.html.erb +1 -0
- data/generators/oauth_provider/templates/authorize_success.html.haml +1 -0
- data/generators/oauth_provider/templates/client_application.rb +57 -0
- data/generators/oauth_provider/templates/client_application_spec.rb +29 -0
- data/generators/oauth_provider/templates/client_application_test.rb +42 -0
- data/generators/oauth_provider/templates/client_applications.yml +23 -0
- data/generators/oauth_provider/templates/clients_controller.rb +52 -0
- data/generators/oauth_provider/templates/clients_controller_spec.rb +176 -0
- data/generators/oauth_provider/templates/clients_controller_test.rb +280 -0
- data/generators/oauth_provider/templates/controller.rb +23 -0
- data/generators/oauth_provider/templates/edit.html.erb +7 -0
- data/generators/oauth_provider/templates/edit.html.haml +4 -0
- data/generators/oauth_provider/templates/index.html.erb +43 -0
- data/generators/oauth_provider/templates/index.html.haml +39 -0
- data/generators/oauth_provider/templates/migration.rb +47 -0
- data/generators/oauth_provider/templates/new.html.erb +5 -0
- data/generators/oauth_provider/templates/new.html.haml +5 -0
- data/generators/oauth_provider/templates/oauth2_authorize.html.erb +16 -0
- data/generators/oauth_provider/templates/oauth2_authorize.html.haml +17 -0
- data/generators/oauth_provider/templates/oauth2_token.rb +20 -0
- data/generators/oauth_provider/templates/oauth2_token_spec.rb +52 -0
- data/generators/oauth_provider/templates/oauth2_verifier.rb +35 -0
- data/generators/oauth_provider/templates/oauth2_verifier_spec.rb +44 -0
- data/generators/oauth_provider/templates/oauth_nonce.rb +13 -0
- data/generators/oauth_provider/templates/oauth_nonce_spec.rb +24 -0
- data/generators/oauth_provider/templates/oauth_nonce_test.rb +26 -0
- data/generators/oauth_provider/templates/oauth_nonces.yml +13 -0
- data/generators/oauth_provider/templates/oauth_token.rb +30 -0
- data/generators/oauth_provider/templates/oauth_token_spec.rb +309 -0
- data/generators/oauth_provider/templates/oauth_token_test.rb +57 -0
- data/generators/oauth_provider/templates/oauth_tokens.yml +17 -0
- data/generators/oauth_provider/templates/request_token.rb +40 -0
- data/generators/oauth_provider/templates/show.html.erb +27 -0
- data/generators/oauth_provider/templates/show.html.haml +30 -0
- data/init.rb +1 -0
- data/install.rb +2 -0
- data/lib/generators/active_record/oauth_consumer_generator.rb +33 -0
- data/lib/generators/active_record/oauth_consumer_templates/consumer_token.rb +11 -0
- data/lib/generators/active_record/oauth_consumer_templates/migration.rb +20 -0
- data/lib/generators/active_record/oauth_provider_generator.rb +39 -0
- data/lib/generators/active_record/oauth_provider_templates/access_token.rb +16 -0
- data/lib/generators/active_record/oauth_provider_templates/client_application.rb +57 -0
- data/lib/generators/active_record/oauth_provider_templates/migration.rb +47 -0
- data/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb +20 -0
- data/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb +35 -0
- data/lib/generators/active_record/oauth_provider_templates/oauth_nonce.rb +13 -0
- data/lib/generators/active_record/oauth_provider_templates/oauth_token.rb +30 -0
- data/lib/generators/active_record/oauth_provider_templates/request_token.rb +40 -0
- data/lib/generators/erb/oauth_consumer_generator.rb +14 -0
- data/lib/generators/erb/oauth_consumer_templates/index.html.erb +29 -0
- data/lib/generators/erb/oauth_consumer_templates/show.html.erb +7 -0
- data/lib/generators/erb/oauth_provider_generator.rb +23 -0
- data/lib/generators/erb/oauth_provider_templates/_form.html.erb +17 -0
- data/lib/generators/erb/oauth_provider_templates/authorize.html.erb +14 -0
- data/lib/generators/erb/oauth_provider_templates/authorize_failure.html.erb +1 -0
- data/lib/generators/erb/oauth_provider_templates/authorize_success.html.erb +1 -0
- data/lib/generators/erb/oauth_provider_templates/edit.html.erb +7 -0
- data/lib/generators/erb/oauth_provider_templates/index.html.erb +43 -0
- data/lib/generators/erb/oauth_provider_templates/new.html.erb +5 -0
- data/lib/generators/erb/oauth_provider_templates/oauth2_authorize.html.erb +16 -0
- data/lib/generators/erb/oauth_provider_templates/show.html.erb +27 -0
- data/lib/generators/haml/oauth_consumer_generator.rb +21 -0
- data/lib/generators/haml/oauth_consumer_templates/index.html.haml +18 -0
- data/lib/generators/haml/oauth_consumer_templates/show.html.haml +8 -0
- data/lib/generators/haml/oauth_provider_generator.rb +28 -0
- data/lib/generators/haml/oauth_provider_templates/_form.html.haml +21 -0
- data/lib/generators/haml/oauth_provider_templates/authorize.html.haml +16 -0
- data/lib/generators/haml/oauth_provider_templates/authorize_failure.html.haml +1 -0
- data/lib/generators/haml/oauth_provider_templates/authorize_success.html.haml +1 -0
- data/lib/generators/haml/oauth_provider_templates/edit.html.haml +4 -0
- data/lib/generators/haml/oauth_provider_templates/index.html.haml +39 -0
- data/lib/generators/haml/oauth_provider_templates/new.html.haml +5 -0
- data/lib/generators/haml/oauth_provider_templates/oauth2_authorize.html.haml +17 -0
- data/lib/generators/haml/oauth_provider_templates/show.html.haml +30 -0
- data/lib/generators/mongoid/oauth_consumer_generator.rb +15 -0
- data/lib/generators/mongoid/oauth_consumer_templates/consumer_token.rb +41 -0
- data/lib/generators/mongoid/oauth_provider_generator.rb +21 -0
- data/lib/generators/mongoid/oauth_provider_templates/access_token.rb +16 -0
- data/lib/generators/mongoid/oauth_provider_templates/client_application.rb +71 -0
- data/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb +20 -0
- data/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb +35 -0
- data/lib/generators/mongoid/oauth_provider_templates/oauth_nonce.rb +24 -0
- data/lib/generators/mongoid/oauth_provider_templates/oauth_token.rb +44 -0
- data/lib/generators/mongoid/oauth_provider_templates/request_token.rb +36 -0
- data/lib/generators/oauth_consumer/USAGE +11 -0
- data/lib/generators/oauth_consumer/oauth_consumer_generator.rb +31 -0
- data/lib/generators/oauth_consumer/templates/controller.rb +59 -0
- data/lib/generators/oauth_consumer/templates/oauth_config.rb +68 -0
- data/lib/generators/oauth_inflections.rb +6 -0
- data/lib/generators/oauth_plugin.rb +0 -0
- data/lib/generators/oauth_provider/USAGE +18 -0
- data/lib/generators/oauth_provider/oauth_provider_generator.rb +37 -0
- data/lib/generators/oauth_provider/templates/clients_controller.rb +52 -0
- data/lib/generators/oauth_provider/templates/controller.rb +23 -0
- data/lib/generators/rspec/oauth_provider_generator.rb +35 -0
- data/lib/generators/rspec/templates/client_application_spec.rb +29 -0
- data/lib/generators/rspec/templates/client_applications.yml +23 -0
- data/lib/generators/rspec/templates/clients_controller_spec.rb +176 -0
- data/lib/generators/rspec/templates/oauth2_token_spec.rb +52 -0
- data/lib/generators/rspec/templates/oauth2_verifier_spec.rb +44 -0
- data/lib/generators/rspec/templates/oauth_nonce_spec.rb +24 -0
- data/lib/generators/rspec/templates/oauth_nonces.yml +13 -0
- data/lib/generators/rspec/templates/oauth_token_spec.rb +309 -0
- data/lib/generators/rspec/templates/oauth_tokens.yml +17 -0
- data/lib/generators/slim/oauth_consumer_generator.rb +21 -0
- data/lib/generators/slim/oauth_consumer_templates/index.html.slim +15 -0
- data/lib/generators/slim/oauth_consumer_templates/show.html.slim +8 -0
- data/lib/generators/test_unit/oauth_provider_generator.rb +33 -0
- data/lib/generators/test_unit/templates/client_application_test.rb +42 -0
- data/lib/generators/test_unit/templates/client_applications.yml +23 -0
- data/lib/generators/test_unit/templates/clients_controller_test.rb +280 -0
- data/lib/generators/test_unit/templates/oauth_nonce_test.rb +26 -0
- data/lib/generators/test_unit/templates/oauth_nonces.yml +13 -0
- data/lib/generators/test_unit/templates/oauth_token_test.rb +57 -0
- data/lib/generators/test_unit/templates/oauth_tokens.yml +17 -0
- data/lib/oauth-plugin.rb +24 -0
- data/lib/oauth-plugin/version.rb +5 -0
- data/lib/oauth/controllers/application_controller_methods.rb +140 -0
- data/lib/oauth/controllers/consumer_controller.rb +153 -0
- data/lib/oauth/controllers/provider_controller.rb +181 -0
- data/lib/oauth/models/consumers/service_loader.rb +28 -0
- data/lib/oauth/models/consumers/services/agree2_token.rb +15 -0
- data/lib/oauth/models/consumers/services/fireeagle_token.rb +39 -0
- data/lib/oauth/models/consumers/services/google_token.rb +21 -0
- data/lib/oauth/models/consumers/services/oauth2_token.rb +49 -0
- data/lib/oauth/models/consumers/services/opentransact_token.rb +15 -0
- data/lib/oauth/models/consumers/services/picomoney_token.rb +17 -0
- data/lib/oauth/models/consumers/services/twitter_token.rb +24 -0
- data/lib/oauth/models/consumers/simple_client.rb +50 -0
- data/lib/oauth/models/consumers/token.rb +121 -0
- data/lib/oauth/provider/authorizer.rb +83 -0
- data/lib/oauth/rack/oauth_filter.rb +97 -0
- data/oauth-plugin.gemspec +40 -0
- data/rails/init.rb +1 -0
- data/spec/dummy_provider_models.rb +53 -0
- data/spec/oauth/provider/authorizer_spec.rb +202 -0
- data/spec/rack/oauth_filter_spec.rb +244 -0
- data/spec/spec_helper.rb +3 -0
- data/tasks/oauth_tasks.rake +4 -0
- data/uninstall.rb +1 -0
- 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,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> </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,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,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
|