sorcery 0.7.4 → 0.7.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.
Potentially problematic release.
This version of sorcery might be problematic. Click here for more details.
- data/Gemfile.lock +2 -2
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/generators/sorcery/install_generator.rb +5 -3
- data/lib/generators/sorcery/templates/initializer.rb +25 -4
- data/lib/sorcery.rb +2 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +17 -18
- data/lib/sorcery/controller/submodules/external/providers/github.rb +11 -3
- data/lib/sorcery/controller/submodules/external/providers/google.rb +89 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +90 -0
- data/lib/sorcery/model.rb +17 -4
- data/lib/sorcery/model/adapters/active_record.rb +6 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +6 -1
- data/lib/sorcery/model/adapters/mongoid.rb +6 -1
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +5 -5
- data/lib/sorcery/model/submodules/reset_password.rb +4 -5
- data/lib/sorcery/model/submodules/user_activation.rb +1 -2
- data/sorcery.gemspec +4 -2
- data/spec/Gemfile.lock +3 -3
- data/spec/rails3/Gemfile +1 -2
- data/spec/rails3/Gemfile.lock +13 -14
- data/spec/rails3/app/controllers/application_controller.rb +26 -2
- data/spec/rails3/spec/controller_oauth2_spec.rb +111 -11
- data/spec/rails3/spec/controller_spec.rb +30 -2
- data/spec/rails3_mongo_mapper/Gemfile.lock +11 -11
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +34 -1
- data/spec/rails3_mongoid/Gemfile.lock +8 -8
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +3 -3
- data/spec/rails3_mongoid/spec/controller_spec.rb +34 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +9 -1
- data/spec/sorcery_crypto_providers_spec.rb +5 -1
- metadata +4 -2
@@ -63,13 +63,41 @@ describe ApplicationController do
|
|
63
63
|
assigns[:user].should == @user
|
64
64
|
session[:user_id].should == @user.id
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "login(username,password) should return nil and not set the session when failure" do
|
68
68
|
get :test_login, :username => 'gizmo', :password => 'opensesame!'
|
69
69
|
assigns[:user].should be_nil
|
70
70
|
session[:user_id].should be_nil
|
71
71
|
end
|
72
|
+
|
73
|
+
it "login(username,password) should return nil and not set the session when upper case username" do
|
74
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
75
|
+
assigns[:user].should be_nil
|
76
|
+
session[:user_id].should be_nil
|
77
|
+
end
|
72
78
|
|
79
|
+
it "login(username,password) should return the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
80
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
81
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
82
|
+
assigns[:user].should == @user
|
83
|
+
session[:user_id].should == @user.id
|
84
|
+
end
|
85
|
+
|
86
|
+
it "login(username,password) should return nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
|
87
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
88
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
89
|
+
assigns[:user].should be_nil
|
90
|
+
session[:user_id].should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "login(username,password) should return the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
94
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
95
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
96
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
97
|
+
assigns[:user].should == @user
|
98
|
+
session[:user_id].should == @user.id
|
99
|
+
end
|
100
|
+
|
73
101
|
it "logout should clear the session" do
|
74
102
|
cookies[:remember_me_token] = nil
|
75
103
|
session[:user_id] = @user.id
|
@@ -139,4 +167,4 @@ describe ApplicationController do
|
|
139
167
|
end
|
140
168
|
end
|
141
169
|
|
142
|
-
end
|
170
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
sorcery (0.7.
|
4
|
+
sorcery (0.7.4)
|
5
5
|
bcrypt-ruby (~> 3.0.0)
|
6
6
|
oauth (~> 0.4.4)
|
7
7
|
oauth (~> 0.4.4)
|
@@ -42,8 +42,8 @@ GEM
|
|
42
42
|
archive-tar-minitar (0.5.2)
|
43
43
|
arel (2.0.10)
|
44
44
|
bcrypt-ruby (3.0.1)
|
45
|
-
bson (1.
|
46
|
-
bson_ext (1.
|
45
|
+
bson (1.4.1)
|
46
|
+
bson_ext (1.4.1)
|
47
47
|
builder (2.1.2)
|
48
48
|
coderay (0.9.8)
|
49
49
|
columnize (0.3.4)
|
@@ -65,22 +65,22 @@ GEM
|
|
65
65
|
method_source (0.6.7)
|
66
66
|
ruby_parser (>= 2.3.1)
|
67
67
|
mime-types (1.17.2)
|
68
|
-
mongo (1.
|
69
|
-
bson (
|
70
|
-
mongo_mapper (0.
|
68
|
+
mongo (1.4.1)
|
69
|
+
bson (= 1.4.1)
|
70
|
+
mongo_mapper (0.10.1)
|
71
71
|
activemodel (~> 3.0)
|
72
72
|
activesupport (~> 3.0)
|
73
|
-
plucky (~> 0.
|
73
|
+
plucky (~> 0.4.0)
|
74
74
|
multi_json (1.0.3)
|
75
75
|
multipart-post (1.1.3)
|
76
76
|
oauth (0.4.5)
|
77
77
|
oauth2 (0.4.1)
|
78
78
|
faraday (~> 0.6.1)
|
79
79
|
multi_json (>= 0.0.5)
|
80
|
-
plucky (0.3
|
80
|
+
plucky (0.4.3)
|
81
81
|
mongo (~> 1.3)
|
82
|
-
polyglot (0.3.
|
83
|
-
pry (0.9.7.
|
82
|
+
polyglot (0.3.3)
|
83
|
+
pry (0.9.7.4)
|
84
84
|
coderay (~> 0.9.8)
|
85
85
|
method_source (~> 0.6.7)
|
86
86
|
ruby_parser (>= 2.3.1)
|
@@ -140,7 +140,7 @@ GEM
|
|
140
140
|
treetop (1.4.10)
|
141
141
|
polyglot
|
142
142
|
polyglot (>= 0.3.1)
|
143
|
-
tzinfo (0.3.
|
143
|
+
tzinfo (0.3.31)
|
144
144
|
|
145
145
|
PLATFORMS
|
146
146
|
ruby
|
@@ -30,11 +30,16 @@ describe ApplicationController do
|
|
30
30
|
before(:all) do
|
31
31
|
sorcery_reload!
|
32
32
|
User.delete_all
|
33
|
+
end
|
34
|
+
|
35
|
+
before(:each) do
|
33
36
|
create_new_user
|
34
37
|
end
|
35
38
|
|
36
39
|
after(:each) do
|
37
40
|
Sorcery::Controller::Config.reset!
|
41
|
+
sorcery_reload!
|
42
|
+
User.delete_all
|
38
43
|
sorcery_controller_property_set(:user_class, User)
|
39
44
|
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
40
45
|
end
|
@@ -64,6 +69,34 @@ describe ApplicationController do
|
|
64
69
|
assigns[:user].should be_nil
|
65
70
|
session[:user_id].should be_nil
|
66
71
|
end
|
72
|
+
|
73
|
+
it "login(username,password) should return nil and not set the session when upper case username" do
|
74
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
75
|
+
assigns[:user].should be_nil
|
76
|
+
session[:user_id].should be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "login(username,password) should return the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
80
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
81
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
82
|
+
assigns[:user].should == @user
|
83
|
+
session[:user_id].should == @user.id
|
84
|
+
end
|
85
|
+
|
86
|
+
it "login(username,password) should return nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
|
87
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
88
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
89
|
+
assigns[:user].should be_nil
|
90
|
+
session[:user_id].should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "login(username,password) should return the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
94
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
95
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
96
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
97
|
+
assigns[:user].should == @user
|
98
|
+
session[:user_id].should == @user.id
|
99
|
+
end
|
67
100
|
|
68
101
|
it "logout should clear the session" do
|
69
102
|
cookies[:remember_me_token] = nil
|
@@ -127,4 +160,4 @@ describe ApplicationController do
|
|
127
160
|
end
|
128
161
|
end
|
129
162
|
|
130
|
-
end
|
163
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
sorcery (0.7.
|
4
|
+
sorcery (0.7.4)
|
5
5
|
bcrypt-ruby (~> 3.0.0)
|
6
6
|
oauth (~> 0.4.4)
|
7
7
|
oauth (~> 0.4.4)
|
@@ -42,8 +42,8 @@ GEM
|
|
42
42
|
archive-tar-minitar (0.5.2)
|
43
43
|
arel (2.0.10)
|
44
44
|
bcrypt-ruby (3.0.1)
|
45
|
-
bson (1.
|
46
|
-
bson_ext (1.
|
45
|
+
bson (1.4.1)
|
46
|
+
bson_ext (1.4.1)
|
47
47
|
builder (2.1.2)
|
48
48
|
columnize (0.3.4)
|
49
49
|
diff-lcs (1.1.3)
|
@@ -62,9 +62,9 @@ GEM
|
|
62
62
|
mime-types (~> 1.16)
|
63
63
|
treetop (~> 1.4.8)
|
64
64
|
mime-types (1.17.2)
|
65
|
-
mongo (1.
|
66
|
-
bson (
|
67
|
-
mongoid (2.2.
|
65
|
+
mongo (1.4.1)
|
66
|
+
bson (= 1.4.1)
|
67
|
+
mongoid (2.2.4)
|
68
68
|
activemodel (~> 3.0)
|
69
69
|
mongo (~> 1.3)
|
70
70
|
tzinfo (~> 0.3.22)
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
oauth2 (0.4.1)
|
75
75
|
faraday (~> 0.6.1)
|
76
76
|
multi_json (>= 0.0.5)
|
77
|
-
polyglot (0.3.
|
77
|
+
polyglot (0.3.3)
|
78
78
|
rack (1.2.4)
|
79
79
|
rack-mount (0.6.14)
|
80
80
|
rack (>= 1.0.0)
|
@@ -126,7 +126,7 @@ GEM
|
|
126
126
|
treetop (1.4.10)
|
127
127
|
polyglot
|
128
128
|
polyglot (>= 0.3.1)
|
129
|
-
tzinfo (0.3.
|
129
|
+
tzinfo (0.3.31)
|
130
130
|
|
131
131
|
PLATFORMS
|
132
132
|
ruby
|
@@ -23,7 +23,7 @@ describe ApplicationController do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should log login time on login" do
|
26
|
-
now = Time.now
|
26
|
+
now = Time.now
|
27
27
|
login_user
|
28
28
|
@user.last_login_at.should_not be_nil
|
29
29
|
@user.last_login_at.to_s(:db).should >= now.to_s(:db)
|
@@ -32,7 +32,7 @@ describe ApplicationController do
|
|
32
32
|
|
33
33
|
it "should log logout time on logout" do
|
34
34
|
login_user
|
35
|
-
now = Time.now
|
35
|
+
now = Time.now
|
36
36
|
logout_user
|
37
37
|
User.first.last_logout_at.should_not be_nil
|
38
38
|
User.first.last_logout_at.to_s(:db).should >= now.to_s(:db)
|
@@ -41,7 +41,7 @@ describe ApplicationController do
|
|
41
41
|
|
42
42
|
it "should log last activity time when logged in" do
|
43
43
|
login_user
|
44
|
-
now = Time.now
|
44
|
+
now = Time.now
|
45
45
|
get :some_action
|
46
46
|
User.first.last_activity_at.to_s(:db).should >= now.to_s(:db)
|
47
47
|
User.first.last_activity_at.to_s(:db).should <= (now+2).to_s(:db)
|
@@ -30,11 +30,16 @@ describe ApplicationController do
|
|
30
30
|
before(:all) do
|
31
31
|
sorcery_reload!
|
32
32
|
User.delete_all
|
33
|
+
end
|
34
|
+
|
35
|
+
before(:each) do
|
33
36
|
create_new_user
|
34
37
|
end
|
35
38
|
|
36
39
|
after(:each) do
|
37
40
|
Sorcery::Controller::Config.reset!
|
41
|
+
sorcery_reload!
|
42
|
+
User.delete_all
|
38
43
|
sorcery_controller_property_set(:user_class, User)
|
39
44
|
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
40
45
|
end
|
@@ -64,7 +69,35 @@ describe ApplicationController do
|
|
64
69
|
assigns[:user].should be_nil
|
65
70
|
session[:user_id].should be_nil
|
66
71
|
end
|
72
|
+
|
73
|
+
it "login(username,password) should return nil and not set the session when upper case username" do
|
74
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
75
|
+
assigns[:user].should be_nil
|
76
|
+
session[:user_id].should be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "login(username,password) should return the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
80
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
81
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
82
|
+
assigns[:user].should == @user
|
83
|
+
session[:user_id].should == @user.id
|
84
|
+
end
|
67
85
|
|
86
|
+
it "login(username,password) should return nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
|
87
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
88
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
89
|
+
assigns[:user].should be_nil
|
90
|
+
session[:user_id].should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "login(username,password) should return the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
94
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
95
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
96
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
97
|
+
assigns[:user].should == @user
|
98
|
+
session[:user_id].should == @user.id
|
99
|
+
end
|
100
|
+
|
68
101
|
it "logout should clear the session" do
|
69
102
|
cookies[:remember_me_token] = nil
|
70
103
|
session[:user_id] = @user.id
|
@@ -138,4 +171,4 @@ describe ApplicationController do
|
|
138
171
|
end
|
139
172
|
end
|
140
173
|
|
141
|
-
end
|
174
|
+
end
|
@@ -150,6 +150,14 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
150
150
|
@user.deliver_reset_password_instructions!
|
151
151
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
152
152
|
end
|
153
|
+
|
154
|
+
it "should return false if time between emails has not passed since last email" do
|
155
|
+
create_new_user
|
156
|
+
sorcery_model_property_set(:reset_password_time_between_emails, 10000)
|
157
|
+
old_size = ActionMailer::Base.deliveries.size
|
158
|
+
@user.deliver_reset_password_instructions!
|
159
|
+
@user.deliver_reset_password_instructions!.should == false
|
160
|
+
end
|
153
161
|
|
154
162
|
it "should send an email if time between emails has passed since last email" do
|
155
163
|
create_new_user
|
@@ -174,4 +182,4 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
174
182
|
end
|
175
183
|
|
176
184
|
end
|
177
|
-
end
|
185
|
+
end
|
@@ -54,7 +54,11 @@ describe "Crypto Providers wrappers" do
|
|
54
54
|
it "matches? returns false when no match" do
|
55
55
|
Sorcery::CryptoProviders::SHA1.matches?(@digest, 'Some Dude').should be_false
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
|
+
it "matches password encrypted using salt and join token from upstream" do
|
59
|
+
Sorcery::CryptoProviders::SHA1.join_token = "test"
|
60
|
+
Sorcery::CryptoProviders::SHA1.encrypt(['password', 'gq18WBnJYNh2arkC1kgH']).should == '894b5bf1643b8d0e1b2eaddb22426be7036dab70'
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
describe Sorcery::CryptoProviders::SHA256 do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sorcery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.5
|
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-
|
13
|
+
date: 2011-11-11 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: oauth
|
@@ -226,6 +226,8 @@ files:
|
|
226
226
|
- lib/sorcery/controller/submodules/external/protocols/oauth2.rb
|
227
227
|
- lib/sorcery/controller/submodules/external/providers/facebook.rb
|
228
228
|
- lib/sorcery/controller/submodules/external/providers/github.rb
|
229
|
+
- lib/sorcery/controller/submodules/external/providers/google.rb
|
230
|
+
- lib/sorcery/controller/submodules/external/providers/liveid.rb
|
229
231
|
- lib/sorcery/controller/submodules/external/providers/twitter.rb
|
230
232
|
- lib/sorcery/controller/submodules/http_basic_auth.rb
|
231
233
|
- lib/sorcery/controller/submodules/remember_me.rb
|