sorcery 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (35) hide show
  1. data/README.rdoc +44 -6
  2. data/VERSION +1 -1
  3. data/lib/generators/sorcery_migration/templates/{oauth.rb → external.rb} +1 -1
  4. data/lib/sorcery/controller/submodules/email.rb +44 -0
  5. data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +35 -0
  6. data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +26 -0
  7. data/lib/sorcery/controller/submodules/{oauth → external}/providers/facebook.rb +24 -6
  8. data/lib/sorcery/controller/submodules/{oauth → external}/providers/twitter.rb +31 -6
  9. data/lib/sorcery/controller/submodules/external.rb +83 -0
  10. data/lib/sorcery/controller.rb +5 -3
  11. data/lib/sorcery/model/submodules/{oauth.rb → external.rb} +3 -3
  12. data/lib/sorcery/model.rb +9 -6
  13. data/lib/sorcery.rb +9 -7
  14. data/sorcery.gemspec +14 -12
  15. data/spec/Gemfile +1 -1
  16. data/spec/Gemfile.lock +2 -2
  17. data/spec/rails3/app_root/Gemfile +1 -1
  18. data/spec/rails3/app_root/Gemfile.lock +2 -2
  19. data/spec/rails3/app_root/app/controllers/application_controller.rb +11 -11
  20. data/spec/rails3/app_root/db/migrate/{oauth → external}/20101224223628_create_authentications.rb +0 -0
  21. data/spec/rails3/app_root/spec/controller_oauth2_spec.rb +13 -13
  22. data/spec/rails3/app_root/spec/controller_oauth_spec.rb +12 -12
  23. data/spec/rails3/app_root/spec/user_oauth_spec.rb +4 -4
  24. data/spec/rails3/app_root/spec/user_spec.rb +2 -2
  25. data/spec/sinatra/Gemfile +1 -1
  26. data/spec/sinatra/Gemfile.lock +2 -2
  27. data/spec/sinatra/db/migrate/{oauth → external}/20101224223628_create_authentications.rb +0 -0
  28. data/spec/sinatra/myapp.rb +11 -11
  29. data/spec/sinatra/spec/controller_oauth2_spec.rb +13 -13
  30. data/spec/sinatra/spec/controller_oauth_spec.rb +12 -12
  31. data/spec/sinatra/spec/user_oauth_spec.rb +4 -4
  32. data/spec/sinatra/spec/user_spec.rb +2 -2
  33. metadata +14 -12
  34. data/lib/sorcery/controller/submodules/oauth/oauth1.rb +0 -33
  35. data/lib/sorcery/controller/submodules/oauth/oauth2.rb +0 -24
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../../
3
3
  specs:
4
- sorcery (0.3.0)
4
+ sorcery (0.3.1)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  json (>= 1.5.1)
7
7
  oauth (>= 0.4.4)
@@ -131,6 +131,6 @@ DEPENDENCIES
131
131
  rspec-rails
132
132
  ruby-debug19
133
133
  simplecov (>= 0.3.8)
134
- sorcery (= 0.3.0)!
134
+ sorcery (= 0.3.1)!
135
135
  spork (~> 0.9.0.rc)
136
136
  sqlite3-ruby
@@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
22
22
 
23
23
  def test_return_to
24
24
  @user = login(params[:username], params[:password])
25
- return_or_redirect_to(:index, :notice => 'haha!')
25
+ redirect_back_or_to(:index, :notice => 'haha!')
26
26
  end
27
27
 
28
28
  def test_logout
@@ -66,24 +66,24 @@ class ApplicationController < ActionController::Base
66
66
  render :text => "HTTP Basic Auth"
67
67
  end
68
68
 
69
- def auth_at_provider_test
70
- auth_at_provider(:twitter)
69
+ def login_at_test
70
+ login_at(:twitter)
71
71
  end
72
72
 
73
- def auth_at_provider_test2
74
- auth_at_provider(:facebook)
73
+ def login_at_test2
74
+ login_at(:facebook)
75
75
  end
76
76
 
77
- def test_login_from_access_token
78
- if @user = login_from_access_token(:twitter)
77
+ def test_login_from
78
+ if @user = login_from(:twitter)
79
79
  redirect_to "bla", :notice => "Success!"
80
80
  else
81
81
  redirect_to "blu", :alert => "Failed!"
82
82
  end
83
83
  end
84
84
 
85
- def test_login_from_access_token2
86
- if @user = login_from_access_token(:facebook)
85
+ def test_login_from2
86
+ if @user = login_from(:facebook)
87
87
  redirect_to "bla", :notice => "Success!"
88
88
  else
89
89
  redirect_to "blu", :alert => "Failed!"
@@ -92,8 +92,8 @@ class ApplicationController < ActionController::Base
92
92
 
93
93
  def test_create_from_provider
94
94
  provider = params[:provider]
95
- login_from_access_token(provider)
96
- if @user = create_from_provider!(provider)
95
+ login_from(provider)
96
+ if @user = create_from(provider)
97
97
  redirect_to "bla", :notice => "Success!"
98
98
  else
99
99
  redirect_to "blu", :alert => "Failed!"
@@ -12,16 +12,16 @@ end
12
12
 
13
13
  describe ApplicationController do
14
14
  before(:all) do
15
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/oauth")
16
- sorcery_reload!([:oauth])
17
- sorcery_controller_property_set(:oauth_providers, [:facebook])
15
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
16
+ sorcery_reload!([:external])
17
+ sorcery_controller_property_set(:external_providers, [:facebook])
18
18
  sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
19
19
  sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
20
20
  sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
21
21
  end
22
22
 
23
23
  after(:all) do
24
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/oauth")
24
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
25
25
  end
26
26
  # ----------------- OAuth -----------------------
27
27
  describe ApplicationController, "with OAuth features" do
@@ -35,29 +35,29 @@ describe ApplicationController do
35
35
  Authentication.delete_all
36
36
  end
37
37
 
38
- it "auth_at_provider redirects correctly" do
38
+ it "login_at redirects correctly" do
39
39
  create_new_user
40
- get :auth_at_provider_test2
40
+ get :login_at_test2
41
41
  response.should be_a_redirect
42
42
  response.should redirect_to("http://myapi.com/oauth/authorize?client_id=key&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&type=web_server")
43
43
  end
44
44
 
45
- it "'login_from_access_token' logins if user exists" do
45
+ it "'login_from' logins if user exists" do
46
46
  sorcery_model_property_set(:authentications_class, Authentication)
47
47
  create_new_external_user(:facebook)
48
- get :test_login_from_access_token2
48
+ get :test_login_from2
49
49
  flash[:notice].should == "Success!"
50
50
  end
51
51
 
52
- it "'login_from_access_token' fails if user doesn't exist" do
52
+ it "'login_from' fails if user doesn't exist" do
53
53
  sorcery_model_property_set(:authentications_class, Authentication)
54
54
  create_new_user
55
- get :test_login_from_access_token2
55
+ get :test_login_from2
56
56
  flash[:alert].should == "Failed!"
57
57
  end
58
58
  end
59
59
 
60
- describe ApplicationController, "'create_from_provider!'" do
60
+ describe ApplicationController, "'create_from'" do
61
61
  before(:each) do
62
62
  stub_all_oauth2_requests!
63
63
  User.delete_all
@@ -86,8 +86,8 @@ describe ApplicationController do
86
86
  describe ApplicationController, "OAuth with User Activation features" do
87
87
  before(:all) do
88
88
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
89
- sorcery_reload!([:user_activation,:oauth], :user_activation_mailer => ::SorceryMailer)
90
- sorcery_controller_property_set(:oauth_providers, [:facebook])
89
+ sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
90
+ sorcery_controller_property_set(:external_providers, [:facebook])
91
91
  sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
92
92
  sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
93
93
  sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
@@ -19,19 +19,19 @@ end
19
19
 
20
20
  describe ApplicationController do
21
21
  before(:all) do
22
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/oauth")
23
- sorcery_reload!([:oauth])
24
- sorcery_controller_property_set(:oauth_providers, [:twitter])
22
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
23
+ sorcery_reload!([:external])
24
+ sorcery_controller_property_set(:external_providers, [:twitter])
25
25
  sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
26
26
  sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
27
27
  sorcery_controller_oauth_property_set(:twitter, :callback_url, "http://blabla.com")
28
28
  end
29
29
 
30
30
  after(:all) do
31
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/oauth")
31
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
32
32
  end
33
33
  # ----------------- OAuth -----------------------
34
- describe ApplicationController, "'login_from_access_token'" do
34
+ describe ApplicationController, "'login_from'" do
35
35
 
36
36
  before(:each) do
37
37
  stub_all_oauth_requests!
@@ -42,9 +42,9 @@ describe ApplicationController do
42
42
  Authentication.delete_all
43
43
  end
44
44
 
45
- it "auth_at_provider redirects correctly" do
45
+ it "login_at redirects correctly" do
46
46
  create_new_user
47
- get :auth_at_provider_test
47
+ get :login_at_test
48
48
  response.should be_a_redirect
49
49
  response.should redirect_to("http://myapi.com/oauth/authorize?oauth_callback=http%3A%2F%2Fblabla.com&oauth_token=")
50
50
  end
@@ -52,19 +52,19 @@ describe ApplicationController do
52
52
  it "logins if user exists" do
53
53
  sorcery_model_property_set(:authentications_class, Authentication)
54
54
  create_new_external_user(:twitter)
55
- get :test_login_from_access_token, :oauth_verifier => "blablaRERASDFcxvSDFA"
55
+ get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
56
56
  flash[:notice].should == "Success!"
57
57
  end
58
58
 
59
- it "'login_from_access_token' fails if user doesn't exist" do
59
+ it "'login_from' fails if user doesn't exist" do
60
60
  sorcery_model_property_set(:authentications_class, Authentication)
61
61
  create_new_user
62
- get :test_login_from_access_token, :oauth_verifier => "blablaRERASDFcxvSDFA"
62
+ get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
63
63
  flash[:alert].should == "Failed!"
64
64
  end
65
65
  end
66
66
 
67
- describe ApplicationController, "'create_from_provider!'" do
67
+ describe ApplicationController, "'create_from'" do
68
68
  before(:each) do
69
69
  stub_all_oauth_requests!
70
70
  User.delete_all
@@ -93,7 +93,7 @@ describe ApplicationController do
93
93
  describe ApplicationController, "OAuth with User Activation features" do
94
94
  before(:all) do
95
95
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
96
- sorcery_reload!([:user_activation,:oauth], :user_activation_mailer => ::SorceryMailer)
96
+ sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
97
97
  end
98
98
 
99
99
  after(:all) do
@@ -2,19 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "User with oauth submodule" do
4
4
  before(:all) do
5
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/oauth")
5
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
6
6
  end
7
7
 
8
8
  after(:all) do
9
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/oauth")
9
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
10
10
  end
11
11
 
12
12
  # ----------------- PLUGIN CONFIGURATION -----------------------
13
13
  describe User, "loaded plugin configuration" do
14
14
 
15
15
  before(:all) do
16
- sorcery_reload!([:oauth])
17
- sorcery_controller_property_set(:oauth_providers, [:twitter])
16
+ sorcery_reload!([:external])
17
+ sorcery_controller_property_set(:external_providers, [:twitter])
18
18
  sorcery_model_property_set(:authentications_class, Authentication)
19
19
  sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
20
20
  sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
@@ -286,12 +286,12 @@ describe "User with no submodules (core)" do
286
286
 
287
287
  describe User, "external users" do
288
288
  before(:all) do
289
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/oauth")
289
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
290
290
  sorcery_reload!()
291
291
  end
292
292
 
293
293
  after(:all) do
294
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/oauth")
294
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
295
295
  end
296
296
 
297
297
  before(:each) do
data/spec/sinatra/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra', '>= 1.2.0'
4
4
  gem 'sqlite3-ruby', :require => 'sqlite3'
5
- gem "sorcery", '0.3.0', :path => '../../'
5
+ gem "sorcery", '0.3.1', :path => '../../'
6
6
 
7
7
  group :development, :test do
8
8
  gem 'rspec'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.3.0)
4
+ sorcery (0.3.1)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  json (>= 1.5.1)
7
7
  oauth (>= 0.4.4)
@@ -129,6 +129,6 @@ DEPENDENCIES
129
129
  ruby-debug19
130
130
  simplecov (>= 0.3.8)
131
131
  sinatra (>= 1.2.0)
132
- sorcery (= 0.3.0)!
132
+ sorcery (= 0.3.1)!
133
133
  spork (~> 0.9.0.rc)
134
134
  sqlite3-ruby
@@ -53,7 +53,7 @@ end
53
53
  post '/test_return_to' do
54
54
  session[:return_to_url] = params[:return_to_url] if params[:return_to_url]
55
55
  @user = login(params[:username], params[:password])
56
- return_or_redirect_to(:some_action)
56
+ redirect_back_or_to(:some_action)
57
57
  end
58
58
 
59
59
  get '/test_should_be_logged_in' do
@@ -96,12 +96,12 @@ end
96
96
 
97
97
  # oauth
98
98
 
99
- get '/auth_at_provider_test' do
100
- auth_at_provider(:twitter)
99
+ get '/login_at_test' do
100
+ login_at(:twitter)
101
101
  end
102
102
 
103
- get '/test_login_from_access_token' do
104
- if @user = login_from_access_token(:twitter)
103
+ get '/test_login_from' do
104
+ if @user = login_from(:twitter)
105
105
  erb "Success!"
106
106
  else
107
107
  erb "Failed!"
@@ -110,12 +110,12 @@ end
110
110
 
111
111
  # oauth2
112
112
 
113
- get '/auth_at_provider_test2' do
114
- auth_at_provider(:facebook)
113
+ get '/login_at_test2' do
114
+ login_at(:facebook)
115
115
  end
116
116
 
117
- get '/test_login_from_access_token2' do
118
- if @user = login_from_access_token(:facebook)
117
+ get '/test_login_from2' do
118
+ if @user = login_from(:facebook)
119
119
  erb "Success!"
120
120
  else
121
121
  erb "Failed!"
@@ -124,8 +124,8 @@ end
124
124
 
125
125
  get '/test_create_from_provider' do
126
126
  provider = params[:provider]
127
- login_from_access_token(provider)
128
- if @user = create_from_provider!(provider)
127
+ login_from(provider)
128
+ if @user = create_from(provider)
129
129
  erb "Success!"
130
130
  else
131
131
  erb "Failed!"
@@ -12,16 +12,16 @@ end
12
12
 
13
13
  describe 'MyApp' do
14
14
  before(:all) do
15
- ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/oauth")
16
- sorcery_reload!([:oauth])
17
- sorcery_controller_property_set(:oauth_providers, [:facebook])
15
+ ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
16
+ sorcery_reload!([:external])
17
+ sorcery_controller_property_set(:external_providers, [:facebook])
18
18
  sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
19
19
  sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
20
20
  sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
21
21
  end
22
22
 
23
23
  after(:all) do
24
- ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/oauth")
24
+ ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/external")
25
25
  end
26
26
  # ----------------- OAuth -----------------------
27
27
  describe Sinatra::Application, "with OAuth features" do
@@ -35,29 +35,29 @@ describe 'MyApp' do
35
35
  Authentication.delete_all
36
36
  end
37
37
 
38
- it "auth_at_provider redirects correctly" do
38
+ it "login_at redirects correctly" do
39
39
  create_new_user
40
- get "/auth_at_provider_test2"
40
+ get "/login_at_test2"
41
41
  last_response.should be_a_redirect
42
42
  last_response.should redirect_to("http://myapi.com/oauth/authorize?client_id=key&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&type=web_server")
43
43
  end
44
44
 
45
- it "'login_from_access_token' logins if user exists" do
45
+ it "'login_from' logins if user exists" do
46
46
  sorcery_model_property_set(:authentications_class, Authentication)
47
47
  create_new_external_user(:facebook)
48
- get "/test_login_from_access_token2"
48
+ get "/test_login_from2"
49
49
  last_response.body.should == "Success!"
50
50
  end
51
51
 
52
- it "'login_from_access_token' fails if user doesn't exist" do
52
+ it "'login_from' fails if user doesn't exist" do
53
53
  sorcery_model_property_set(:authentications_class, Authentication)
54
54
  create_new_user
55
- get "/test_login_from_access_token2"
55
+ get "/test_login_from2"
56
56
  last_response.body.should == "Failed!"
57
57
  end
58
58
  end
59
59
 
60
- describe Sinatra::Application, "'create_from_provider!'" do
60
+ describe Sinatra::Application, "'create_from'" do
61
61
  before(:each) do
62
62
  stub_all_oauth2_requests!
63
63
  User.delete_all
@@ -86,8 +86,8 @@ describe 'MyApp' do
86
86
  describe Sinatra::Application, "OAuth with User Activation features" do
87
87
  before(:all) do
88
88
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/activation")
89
- sorcery_reload!([:user_activation,:oauth], :user_activation_mailer => ::SorceryMailer)
90
- sorcery_controller_property_set(:oauth_providers, [:facebook])
89
+ sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
90
+ sorcery_controller_property_set(:external_providers, [:facebook])
91
91
  sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
92
92
  sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
93
93
  sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
@@ -18,19 +18,19 @@ end
18
18
 
19
19
  describe Sinatra::Application do
20
20
  before(:all) do
21
- ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/oauth")
22
- sorcery_reload!([:oauth])
23
- sorcery_controller_property_set(:oauth_providers, [:twitter])
21
+ ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
22
+ sorcery_reload!([:external])
23
+ sorcery_controller_property_set(:external_providers, [:twitter])
24
24
  sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
25
25
  sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
26
26
  sorcery_controller_oauth_property_set(:twitter, :callback_url, "http://blabla.com")
27
27
  end
28
28
 
29
29
  after(:all) do
30
- ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/oauth")
30
+ ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/external")
31
31
  end
32
32
  # ----------------- OAuth -----------------------
33
- describe Sinatra::Application, "'login_from_access_token'" do
33
+ describe Sinatra::Application, "'login_from'" do
34
34
 
35
35
  before(:each) do
36
36
  stub_all_oauth_requests!
@@ -41,9 +41,9 @@ describe Sinatra::Application do
41
41
  Authentication.delete_all
42
42
  end
43
43
 
44
- it "auth_at_provider redirects correctly" do
44
+ it "login_at_test redirects correctly" do
45
45
  create_new_user
46
- get "/auth_at_provider_test"
46
+ get "/login_at_test"
47
47
  last_response.should be_a_redirect
48
48
  last_response.should redirect_to("http://myapi.com/oauth/authorize?oauth_callback=http%3A%2F%2Fblabla.com&oauth_token=")
49
49
  end
@@ -51,19 +51,19 @@ describe Sinatra::Application do
51
51
  it "logins if user exists" do
52
52
  sorcery_model_property_set(:authentications_class, Authentication)
53
53
  create_new_external_user(:twitter)
54
- get '/test_login_from_access_token', :oauth_verifier => "blablaRERASDFcxvSDFA"
54
+ get '/test_login_from', :oauth_verifier => "blablaRERASDFcxvSDFA"
55
55
  last_response.body.should == "Success!"
56
56
  end
57
57
 
58
- it "'login_from_access_token' fails if user doesn't exist" do
58
+ it "'login_from' fails if user doesn't exist" do
59
59
  sorcery_model_property_set(:authentications_class, Authentication)
60
60
  create_new_user
61
- get :test_login_from_access_token, :oauth_verifier => "blablaRERASDFcxvSDFA"
61
+ get '/test_login_from', :oauth_verifier => "blablaRERASDFcxvSDFA"
62
62
  last_response.body.should == "Failed!"
63
63
  end
64
64
  end
65
65
 
66
- describe Sinatra::Application, "'create_from_provider!'" do
66
+ describe Sinatra::Application, "'create_from'" do
67
67
  before(:each) do
68
68
  stub_all_oauth_requests!
69
69
  User.delete_all
@@ -92,7 +92,7 @@ describe Sinatra::Application do
92
92
  describe Sinatra::Application, "OAuth with User Activation features" do
93
93
  before(:all) do
94
94
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/activation")
95
- sorcery_reload!([:user_activation,:oauth], :user_activation_mailer => ::SorceryMailer)
95
+ sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
96
96
  end
97
97
 
98
98
  after(:all) do
@@ -2,19 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "User with oauth submodule" do
4
4
  before(:all) do
5
- ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/oauth")
5
+ ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
6
6
  end
7
7
 
8
8
  after(:all) do
9
- ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/oauth")
9
+ ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/external")
10
10
  end
11
11
 
12
12
  # ----------------- PLUGIN CONFIGURATION -----------------------
13
13
  describe User, "loaded plugin configuration" do
14
14
 
15
15
  before(:all) do
16
- sorcery_reload!([:oauth])
17
- sorcery_controller_property_set(:oauth_providers, [:twitter])
16
+ sorcery_reload!([:external])
17
+ sorcery_controller_property_set(:external_providers, [:twitter])
18
18
  sorcery_model_property_set(:authentications_class, Authentication)
19
19
  sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
20
20
  sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
@@ -286,12 +286,12 @@ describe "User with no submodules (core)" do
286
286
 
287
287
  describe User, "external users" do
288
288
  before(:all) do
289
- ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/oauth")
289
+ ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
290
290
  sorcery_reload!()
291
291
  end
292
292
 
293
293
  after(:all) do
294
- ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/oauth")
294
+ ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/external")
295
295
  end
296
296
 
297
297
  before(:each) do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sorcery
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Noam Ben Ari
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-04 00:00:00 +03:00
13
+ date: 2011-04-17 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -200,7 +200,7 @@ files:
200
200
  - lib/generators/sorcery_migration/templates/activity_logging.rb
201
201
  - lib/generators/sorcery_migration/templates/brute_force_protection.rb
202
202
  - lib/generators/sorcery_migration/templates/core.rb
203
- - lib/generators/sorcery_migration/templates/oauth.rb
203
+ - lib/generators/sorcery_migration/templates/external.rb
204
204
  - lib/generators/sorcery_migration/templates/remember_me.rb
205
205
  - lib/generators/sorcery_migration/templates/reset_password.rb
206
206
  - lib/generators/sorcery_migration/templates/user_activation.rb
@@ -209,12 +209,14 @@ files:
209
209
  - lib/sorcery/controller/adapters/sinatra.rb
210
210
  - lib/sorcery/controller/submodules/activity_logging.rb
211
211
  - lib/sorcery/controller/submodules/brute_force_protection.rb
212
+ - lib/sorcery/controller/submodules/email.rb
213
+ - lib/sorcery/controller/submodules/external.rb
214
+ - lib/sorcery/controller/submodules/external/protocols/oauth1.rb
215
+ - lib/sorcery/controller/submodules/external/protocols/oauth2.rb
216
+ - lib/sorcery/controller/submodules/external/providers/facebook.rb
217
+ - lib/sorcery/controller/submodules/external/providers/twitter.rb
212
218
  - lib/sorcery/controller/submodules/http_basic_auth.rb
213
219
  - lib/sorcery/controller/submodules/oauth.rb
214
- - lib/sorcery/controller/submodules/oauth/oauth1.rb
215
- - lib/sorcery/controller/submodules/oauth/oauth2.rb
216
- - lib/sorcery/controller/submodules/oauth/providers/facebook.rb
217
- - lib/sorcery/controller/submodules/oauth/providers/twitter.rb
218
220
  - lib/sorcery/controller/submodules/remember_me.rb
219
221
  - lib/sorcery/controller/submodules/session_timeout.rb
220
222
  - lib/sorcery/crypto_providers/aes256.rb
@@ -227,7 +229,7 @@ files:
227
229
  - lib/sorcery/model.rb
228
230
  - lib/sorcery/model/submodules/activity_logging.rb
229
231
  - lib/sorcery/model/submodules/brute_force_protection.rb
230
- - lib/sorcery/model/submodules/oauth.rb
232
+ - lib/sorcery/model/submodules/external.rb
231
233
  - lib/sorcery/model/submodules/remember_me.rb
232
234
  - lib/sorcery/model/submodules/reset_password.rb
233
235
  - lib/sorcery/model/submodules/user_activation.rb
@@ -280,7 +282,7 @@ files:
280
282
  - spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb
281
283
  - spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb
282
284
  - spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb
283
- - spec/rails3/app_root/db/migrate/oauth/20101224223628_create_authentications.rb
285
+ - spec/rails3/app_root/db/migrate/external/20101224223628_create_authentications.rb
284
286
  - spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb
285
287
  - spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb
286
288
  - spec/rails3/app_root/db/schema.rb
@@ -327,7 +329,7 @@ files:
327
329
  - spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb
328
330
  - spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb
329
331
  - spec/sinatra/db/migrate/core/20101224223620_create_users.rb
330
- - spec/sinatra/db/migrate/oauth/20101224223628_create_authentications.rb
332
+ - spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb
331
333
  - spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb
332
334
  - spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb
333
335
  - spec/sinatra/filters.rb
@@ -406,7 +408,7 @@ test_files:
406
408
  - spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb
407
409
  - spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb
408
410
  - spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb
409
- - spec/rails3/app_root/db/migrate/oauth/20101224223628_create_authentications.rb
411
+ - spec/rails3/app_root/db/migrate/external/20101224223628_create_authentications.rb
410
412
  - spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb
411
413
  - spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb
412
414
  - spec/rails3/app_root/db/schema.rb
@@ -433,7 +435,7 @@ test_files:
433
435
  - spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb
434
436
  - spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb
435
437
  - spec/sinatra/db/migrate/core/20101224223620_create_users.rb
436
- - spec/sinatra/db/migrate/oauth/20101224223628_create_authentications.rb
438
+ - spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb
437
439
  - spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb
438
440
  - spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb
439
441
  - spec/sinatra/filters.rb
@@ -1,33 +0,0 @@
1
- require 'oauth'
2
- module Sorcery
3
- module Controller
4
- module Submodules
5
- module Oauth
6
- module Oauth1
7
- def oauth_version
8
- "1.0"
9
- end
10
-
11
- def get_request_token(token=nil,secret=nil)
12
- return ::OAuth::RequestToken.new(get_consumer,token,secret) if token && secret
13
- get_consumer.get_request_token(:oauth_callback => @callback_url)
14
- end
15
-
16
- def authorize_url(args)
17
- get_request_token(args[:request_token],args[:request_token_secret]).authorize_url(:oauth_callback => @callback_url)
18
- end
19
-
20
- def get_access_token(args)
21
- get_request_token(args[:request_token],args[:request_token_secret]).get_access_token(:oauth_verifier => args[:oauth_verifier])
22
- end
23
-
24
- protected
25
-
26
- def get_consumer
27
- ::OAuth::Consumer.new(@key, @secret, :site => @site)
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end