casino_core-authenticator-activerecord 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -0
- data/casino_core-authenticator-activerecord.gemspec +1 -0
- data/lib/casino_core/authenticator/activerecord.rb +15 -0
- data/lib/casino_core/authenticator/activerecord/version.rb +1 -1
- data/spec/casino_core/authenticator/activerecord_spec.rb +12 -0
- metadata +17 -2
- data/VERSION +0 -1
data/Gemfile.lock
CHANGED
@@ -3,6 +3,7 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
casino_core-authenticator-activerecord (0.0.1)
|
5
5
|
activerecord (~> 3.2.12)
|
6
|
+
bcrypt-ruby (~> 3.0.1)
|
6
7
|
unix-crypt (~> 1.0.2)
|
7
8
|
|
8
9
|
GEM
|
@@ -20,6 +21,7 @@ GEM
|
|
20
21
|
i18n (~> 0.6)
|
21
22
|
multi_json (~> 1.0)
|
22
23
|
arel (3.0.2)
|
24
|
+
bcrypt-ruby (3.0.1)
|
23
25
|
builder (3.0.4)
|
24
26
|
diff-lcs (1.1.3)
|
25
27
|
i18n (0.6.1)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'unix_crypt'
|
3
|
+
require 'bcrypt'
|
3
4
|
|
4
5
|
class CASinoCore::Authenticator::ActiveRecord
|
5
6
|
|
@@ -32,6 +33,20 @@ class CASinoCore::Authenticator::ActiveRecord
|
|
32
33
|
|
33
34
|
private
|
34
35
|
def valid_password?(password, password_from_database)
|
36
|
+
magic = password_from_database.split('$')[1]
|
37
|
+
case magic
|
38
|
+
when /\A2a?\z/
|
39
|
+
valid_password_with_bcrypt?(password, password_from_database)
|
40
|
+
else
|
41
|
+
valid_password_with_unix_crypt?(password, password_from_database)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid_password_with_bcrypt?(password, password_from_database)
|
46
|
+
BCrypt::Password.new(password_from_database) == password
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid_password_with_unix_crypt?(password, password_from_database)
|
35
50
|
UnixCrypt.valid?(password, password_from_database)
|
36
51
|
end
|
37
52
|
|
@@ -64,6 +64,18 @@ describe CASinoCore::Authenticator::ActiveRecord do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
context 'support for bcrypt' do
|
68
|
+
before do
|
69
|
+
CASinoCore::Authenticator::ActiveRecord::User.create!(
|
70
|
+
username: 'test2',
|
71
|
+
password: '$2a$10$dRFLSkYedQ05sqMs3b265e0nnJSoa9RhbpKXU79FDPVeuS1qBG7Jq', # password: testpassword2
|
72
|
+
mail_address: 'mail@example.org')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'is able to handle bcrypt password hashes' do
|
76
|
+
@authenticator.validate('test2', 'testpassword2').should be_instance_of(Hash)
|
77
|
+
end
|
78
|
+
end
|
67
79
|
|
68
80
|
end
|
69
81
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casino_core-authenticator-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -108,6 +108,22 @@ dependencies:
|
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.0.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bcrypt-ruby
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 3.0.1
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ~>
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 3.0.1
|
111
127
|
description: This gem can be used to allow the CASinoCore backend to authenticate
|
112
128
|
against an SQL server using ActiveRecord.
|
113
129
|
email:
|
@@ -124,7 +140,6 @@ files:
|
|
124
140
|
- LICENSE.txt
|
125
141
|
- README.md
|
126
142
|
- Rakefile
|
127
|
-
- VERSION
|
128
143
|
- casino_core-authenticator-activerecord.gemspec
|
129
144
|
- lib/casino_core-authenticator-activerecord.rb
|
130
145
|
- lib/casino_core/authenticator/activerecord.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|