oauth-plugin 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/CHANGELOG +76 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +375 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/generators/oauth_consumer/USAGE +10 -0
- data/generators/oauth_consumer/oauth_consumer_generator.rb +49 -0
- data/generators/oauth_consumer/templates/consumer_token.rb +5 -0
- data/generators/oauth_consumer/templates/controller.rb +14 -0
- data/generators/oauth_consumer/templates/migration.rb +20 -0
- data/generators/oauth_consumer/templates/oauth_config.rb +37 -0
- data/generators/oauth_consumer/templates/show.html.erb +7 -0
- data/generators/oauth_consumer/templates/show.html.haml +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 +124 -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 +10 -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 +55 -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 +239 -0
- data/generators/oauth_provider/templates/clients_controller_test.rb +280 -0
- data/generators/oauth_provider/templates/controller.rb +5 -0
- data/generators/oauth_provider/templates/controller_spec.rb +367 -0
- data/generators/oauth_provider/templates/controller_spec_helper.rb +80 -0
- data/generators/oauth_provider/templates/controller_test.rb +310 -0
- data/generators/oauth_provider/templates/controller_test_helper.rb +115 -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 +46 -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/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 +31 -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 +7 -0
- data/install.rb +2 -0
- data/lib/oauth/controllers/application_controller_methods.rb +110 -0
- data/lib/oauth/controllers/consumer_controller.rb +69 -0
- data/lib/oauth/controllers/provider_controller.rb +78 -0
- data/lib/oauth/models/consumers/service_loader.rb +18 -0
- data/lib/oauth/models/consumers/services/agree2_token.rb +14 -0
- data/lib/oauth/models/consumers/services/twitter_token.rb +19 -0
- data/lib/oauth/models/consumers/token.rb +60 -0
- data/oauth-plugin.gemspec +104 -0
- data/tasks/oauth_tasks.rake +4 -0
- data/uninstall.rb +1 -0
- metadata +131 -0
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the oauth plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the oauth plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Oauth'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'jeweler'
|
26
|
+
Jeweler::Tasks.new do |gemspec|
|
27
|
+
gemspec.name = "oauth-plugin"
|
28
|
+
gemspec.summary = "Ruby on Rails Plugin for OAuth Provider and Consumer"
|
29
|
+
gemspec.description = "Rails plugin for implementing an OAuth Provider or Consumer"
|
30
|
+
gemspec.email = "oauth-ruby@googlegroups.com"
|
31
|
+
gemspec.homepage = "http://github.com/pelle/oauth-plugin/tree/master"
|
32
|
+
gemspec.authors = ["Pelle Braendgaard"]
|
33
|
+
gemspec.add_dependency('oauth', '>= 0.3.5')
|
34
|
+
gemspec.rubyforge_project = 'oauth'
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
38
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.5
|
@@ -0,0 +1,10 @@
|
|
1
|
+
./script/generate oauth_consumer
|
2
|
+
|
3
|
+
This creates an OAuth Provider controller as well as requisite models.
|
4
|
+
|
5
|
+
It requires an authentication framework such as acts_as_authenticated, restful_authentication or restful_open_id_authentication that provides the methods "login_required" and "current_user".
|
6
|
+
|
7
|
+
If you generated the migration file (true by default), make sure you run
|
8
|
+
rake db:migrate
|
9
|
+
|
10
|
+
See README.rdoc for more.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../oauth_provider/lib/insert_routes.rb")
|
2
|
+
|
3
|
+
class OauthConsumerGenerator < Rails::Generator::Base
|
4
|
+
default_options :skip_migration => false
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
record do |m|
|
8
|
+
|
9
|
+
# Controller, helper, views, and test directories.
|
10
|
+
m.directory File.join('app/models')
|
11
|
+
m.directory File.join('app/controllers')
|
12
|
+
m.directory File.join('app/helpers')
|
13
|
+
m.directory File.join('app/views', 'oauth_consumers')
|
14
|
+
m.directory File.join('config/initializers')
|
15
|
+
|
16
|
+
m.template 'oauth_config.rb',File.join('config/initializers', "oauth_consumers.rb")
|
17
|
+
m.template 'consumer_token.rb',File.join('app/models',"consumer_token.rb")
|
18
|
+
|
19
|
+
m.template 'controller.rb',File.join('app/controllers',"oauth_consumers_controller.rb")
|
20
|
+
m.route_entry "map.resources :oauth_consumers,:member=>{:callback=>:get}"
|
21
|
+
|
22
|
+
@template_extension= options[:haml] ? "haml" : "erb"
|
23
|
+
|
24
|
+
m.template "show.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "show.html.#{@template_extension}")
|
25
|
+
|
26
|
+
unless options[:skip_migration]
|
27
|
+
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
28
|
+
:migration_name => "CreateOauthConsumerTokens"
|
29
|
+
}, :migration_file_name => "create_oauth_consumer_tokens"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def banner
|
36
|
+
"Usage: #{$0} #{spec.name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_options!(opt)
|
40
|
+
opt.separator ''
|
41
|
+
opt.separator 'Options:'
|
42
|
+
opt.on("--skip-migration",
|
43
|
+
"Don't generate a migration file") { |v| options[:skip_migration] = v }
|
44
|
+
# opt.on("--test-unit",
|
45
|
+
# "Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
|
46
|
+
opt.on("--haml",
|
47
|
+
"Templates use haml") { |v| options[:haml] = v }
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'oauth/controllers/consumer_controller'
|
2
|
+
class OauthConsumersController < ApplicationController
|
3
|
+
include Oauth::Controllers::ConsumerController
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
# Change this to decide where you want to redirect user to after callback is finished.
|
8
|
+
# params[:id] holds the service name so you could use this to redirect to various parts
|
9
|
+
# of your application depending on what service you're connecting to.
|
10
|
+
def go_back
|
11
|
+
redirect_to root_url
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateOauthConsumerTokens < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
create_table :consumer_tokens do |t|
|
5
|
+
t.integer :user_id
|
6
|
+
t.string :type, :limit => 30
|
7
|
+
t.string :token
|
8
|
+
t.string :secret
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :consumer_tokens, :token, :unique
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :consumer_tokens
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# edit this file to contain credentials for the OAuth services you support.
|
2
|
+
# each entry needs a corresponding token model.
|
3
|
+
#
|
4
|
+
# eg. :twitter => TwitterToken, :hour_feed => HourFeedToken etc.
|
5
|
+
#
|
6
|
+
# OAUTH_CREDENTIALS={
|
7
|
+
# :twitter=>{
|
8
|
+
# :key=>"",
|
9
|
+
# :secret=>""
|
10
|
+
# },
|
11
|
+
# :agree2=>{
|
12
|
+
# :key=>"",
|
13
|
+
# :secret=>""
|
14
|
+
# },
|
15
|
+
# :hour_feed=>{
|
16
|
+
# :key=>"",
|
17
|
+
# :secret=>"",
|
18
|
+
# :options=>{ # OAuth::Consumer options
|
19
|
+
# :site=>"http://hourfeed.com" # Remember to add a site for a generic OAuth site
|
20
|
+
# }
|
21
|
+
# },
|
22
|
+
# :nu_bux=>{
|
23
|
+
# :key=>"",
|
24
|
+
# :secret=>"",
|
25
|
+
# :super_class=>"OpenTransactToken", # if a OAuth service follows a particular standard
|
26
|
+
# # with a token implementation you can set the superclass
|
27
|
+
# # to use
|
28
|
+
# :options=>{ # OAuth::Consumer options
|
29
|
+
# :site=>"http://nubux.heroku.com"
|
30
|
+
# }
|
31
|
+
# }
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
OAUTH_CREDENTIALS={
|
35
|
+
} unless defined? OAUTH_CREDENTIALS
|
36
|
+
|
37
|
+
load 'oauth/models/consumers/service_loader.rb'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
./script/generate oauth_provider
|
2
|
+
|
3
|
+
This creates an OAuth Provider controller as well as the requisite models.
|
4
|
+
|
5
|
+
It requires an authentication framework such as acts_as_authenticated, restful_authentication or restful_open_id_authentication.
|
6
|
+
|
7
|
+
If you generated the migration file (true by default), make sure you run
|
8
|
+
|
9
|
+
rake db:migrate
|
10
|
+
|
11
|
+
include the following in your user.rb
|
12
|
+
|
13
|
+
has_many :client_applications
|
14
|
+
has_many :tokens, :class_name=>"OauthToken",:order=>"authorized_at desc",:include=>[:client_application]
|
15
|
+
|
16
|
+
For legacy OAUTH 1.0 support add the following constant in your environment.rb
|
17
|
+
|
18
|
+
OAUTH_10_SUPPORT = true
|
19
|
+
|
20
|
+
Note, you should only do this if you really positively require to support old OAuth1.0 clients. There is a serious security issue with this.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Stolen from http://github.com/technoweenie/restful-authentication
|
2
|
+
|
3
|
+
Rails::Generator::Commands::Create.class_eval do
|
4
|
+
def route_entry(raw)
|
5
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
6
|
+
|
7
|
+
logger.route raw
|
8
|
+
unless options[:pretend]
|
9
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
10
|
+
"#{match}\n #{raw}\n"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def route_resource(*resources)
|
16
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
17
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
18
|
+
|
19
|
+
logger.route "map.resource #{resource_list}"
|
20
|
+
unless options[:pretend]
|
21
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
22
|
+
"#{match}\n map.resource #{resource_list}\n"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def route_name(name, path, route_options = {})
|
28
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
29
|
+
|
30
|
+
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
31
|
+
unless options[:pretend]
|
32
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
33
|
+
"#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Rails::Generator::Commands::Destroy.class_eval do
|
40
|
+
def route_resource(*resources)
|
41
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
42
|
+
look_for = "\n map.resource #{resource_list}\n"
|
43
|
+
logger.route "map.resource #{resource_list}"
|
44
|
+
unless options[:pretend]
|
45
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def route_name(name, path, route_options = {})
|
50
|
+
look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
51
|
+
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
52
|
+
unless options[:pretend]
|
53
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Rails::Generator::Commands::List.class_eval do
|
59
|
+
def route_resource(*resources)
|
60
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
61
|
+
logger.route "map.resource #{resource_list}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def route_name(name, path, options = {})
|
65
|
+
logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_routes.rb")
|
2
|
+
class OauthProviderGenerator < Rails::Generator::Base
|
3
|
+
default_options :skip_migration => false
|
4
|
+
attr_reader :class_path,
|
5
|
+
:controller_name,
|
6
|
+
:controller_class_path,
|
7
|
+
:controller_file_path,
|
8
|
+
:controller_class_name,
|
9
|
+
:controller_singular_name,
|
10
|
+
:controller_plural_name
|
11
|
+
alias_method :controller_file_name, :controller_singular_name
|
12
|
+
|
13
|
+
def initialize(runtime_args, runtime_options = {})
|
14
|
+
super
|
15
|
+
|
16
|
+
@controller_name = args.shift || 'oauth'
|
17
|
+
@controller_singular_name = 'oauth'
|
18
|
+
@controller_plural_name = 'oauth'
|
19
|
+
@controller_file_name = 'oauth'
|
20
|
+
@controller_class_name="Oauth"
|
21
|
+
@class_path=''
|
22
|
+
@controller_class_path=''
|
23
|
+
end
|
24
|
+
|
25
|
+
def manifest
|
26
|
+
record do |m|
|
27
|
+
|
28
|
+
# Check for class naming collisions.
|
29
|
+
# Check for class naming collisions.
|
30
|
+
m.class_collisions controller_class_path, "#{controller_class_name}Controller", # Oauth Controller
|
31
|
+
"#{controller_class_name}Helper",
|
32
|
+
"#{controller_class_name}ClientsController",
|
33
|
+
"#{controller_class_name}ClientsHelper"
|
34
|
+
m.class_collisions class_path, "ClientApplication","OauthNonce","RequestToken","AccessToken","OauthToken"
|
35
|
+
|
36
|
+
# Controller, model, views, and test directories.
|
37
|
+
m.directory File.join('app/models', class_path)
|
38
|
+
m.directory File.join('app/controllers', controller_class_path)
|
39
|
+
m.directory File.join('app/views', controller_class_path, controller_file_name)
|
40
|
+
m.directory File.join('app/views', controller_class_path, 'oauth_clients')
|
41
|
+
|
42
|
+
m.template 'client_application.rb',File.join('app/models',"client_application.rb")
|
43
|
+
m.template 'oauth_token.rb', File.join('app/models',"oauth_token.rb")
|
44
|
+
m.template 'request_token.rb', File.join('app/models',"request_token.rb")
|
45
|
+
m.template 'access_token.rb', File.join('app/models',"access_token.rb")
|
46
|
+
m.template 'oauth_nonce.rb', File.join('app/models',"oauth_nonce.rb")
|
47
|
+
|
48
|
+
m.template 'controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_controller.rb")
|
49
|
+
|
50
|
+
m.template 'clients_controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_clients_controller.rb")
|
51
|
+
m.route_name 'oauth', '/oauth',:controller=>'oauth',:action=>'index'
|
52
|
+
m.route_name 'authorize', '/oauth/authorize',:controller=>'oauth',:action=>'authorize'
|
53
|
+
m.route_name 'request_token', '/oauth/request_token',:controller=>'oauth',:action=>'request_token'
|
54
|
+
m.route_name 'access_token', '/oauth/access_token',:controller=>'oauth',:action=>'access_token'
|
55
|
+
m.route_name 'test_request', '/oauth/test_request',:controller=>'oauth',:action=>'test_request'
|
56
|
+
m.route_resources "#{controller_file_name}_clients".to_sym
|
57
|
+
|
58
|
+
if !options[:test_unit]
|
59
|
+
m.directory File.join('spec')
|
60
|
+
m.directory File.join('spec/models')
|
61
|
+
m.directory File.join('spec/fixtures', class_path)
|
62
|
+
m.directory File.join('spec/controllers', controller_class_path)
|
63
|
+
|
64
|
+
m.template 'client_application_spec.rb',File.join('spec/models',"client_application_spec.rb")
|
65
|
+
m.template 'oauth_token_spec.rb', File.join('spec/models',"oauth_token_spec.rb")
|
66
|
+
m.template 'oauth_nonce_spec.rb', File.join('spec/models',"oauth_nonce_spec.rb")
|
67
|
+
m.template 'client_applications.yml',File.join('spec/fixtures',"client_applications.yml")
|
68
|
+
m.template 'oauth_tokens.yml', File.join('spec/fixtures',"oauth_tokens.yml")
|
69
|
+
m.template 'oauth_nonces.yml', File.join('spec/fixtures',"oauth_nonces.yml")
|
70
|
+
m.template 'controller_spec_helper.rb', File.join('spec/controllers', controller_class_path,"#{controller_file_name}_controller_spec_helper.rb")
|
71
|
+
m.template 'controller_spec.rb',File.join('spec/controllers',controller_class_path,"#{controller_file_name}_controller_spec.rb")
|
72
|
+
m.template 'clients_controller_spec.rb',File.join('spec/controllers',controller_class_path,"#{controller_file_name}_clients_controller_spec.rb")
|
73
|
+
else
|
74
|
+
m.directory File.join('test')
|
75
|
+
m.directory File.join('test/unit')
|
76
|
+
m.directory File.join('test/fixtures', class_path)
|
77
|
+
m.directory File.join('test/functional', controller_class_path)
|
78
|
+
m.template 'client_application_test.rb',File.join('test/unit',"client_application_test.rb")
|
79
|
+
m.template 'oauth_token_test.rb', File.join('test/unit',"oauth_token_test.rb")
|
80
|
+
m.template 'oauth_nonce_test.rb', File.join('test/unit',"oauth_nonce_test.rb")
|
81
|
+
m.template 'client_applications.yml',File.join('test/fixtures',"client_applications.yml")
|
82
|
+
m.template 'oauth_tokens.yml', File.join('test/fixtures',"oauth_tokens.yml")
|
83
|
+
m.template 'oauth_nonces.yml', File.join('test/fixtures',"oauth_nonces.yml")
|
84
|
+
m.template 'controller_test_helper.rb', File.join('test', controller_class_path,"#{controller_file_name}_controller_test_helper.rb")
|
85
|
+
m.template 'controller_test.rb',File.join('test/functional',controller_class_path,"#{controller_file_name}_controller_test.rb")
|
86
|
+
m.template 'clients_controller_test.rb',File.join('test/functional',controller_class_path,"#{controller_file_name}_clients_controller_test.rb")
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
@template_extension= options[:haml] ? "haml" : "erb"
|
91
|
+
|
92
|
+
m.template "_form.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "_form.html.#{@template_extension}")
|
93
|
+
m.template "new.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "new.html.#{@template_extension}")
|
94
|
+
m.template "index.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "index.html.#{@template_extension}")
|
95
|
+
m.template "show.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "show.html.#{@template_extension}")
|
96
|
+
m.template "edit.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "edit.html.#{@template_extension}")
|
97
|
+
m.template "authorize.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize.html.#{@template_extension}")
|
98
|
+
m.template "authorize_success.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_success.html.#{@template_extension}")
|
99
|
+
m.template "authorize_failure.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_failure.html.#{@template_extension}")
|
100
|
+
|
101
|
+
unless options[:skip_migration]
|
102
|
+
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
103
|
+
:migration_name => "CreateOauthTables"
|
104
|
+
}, :migration_file_name => "create_oauth_tables"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
protected
|
110
|
+
def banner
|
111
|
+
"Usage: #{$0} #{spec.name}"
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_options!(opt)
|
115
|
+
opt.separator ''
|
116
|
+
opt.separator 'Options:'
|
117
|
+
opt.on("--skip-migration",
|
118
|
+
"Don't generate a migration file") { |v| options[:skip_migration] = v }
|
119
|
+
opt.on("--test-unit",
|
120
|
+
"Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
|
121
|
+
opt.on("--haml",
|
122
|
+
"Templates use haml") { |v| options[:haml] = v }
|
123
|
+
end
|
124
|
+
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,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
|
+
|