letmein 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -10
- data/VERSION +1 -1
- data/letmein.gemspec +3 -3
- data/lib/letmein.rb +1 -1
- data/test/letmein_test.rb +11 -0
- metadata +49 -52
data/README.md
CHANGED
@@ -12,12 +12,12 @@ Plug the thing below into Gemfile and you know what to do after.
|
|
12
12
|
|
13
13
|
If you want to authenticate *User* with database fields *email*, *password_hash* and *password_salt* you don't need to do anything. If you're authenticating something else, you want something like this in your initializers:
|
14
14
|
|
15
|
-
LetMeIn.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
LetMeIn.configure do |conf|
|
16
|
+
conf.model = 'Account'
|
17
|
+
conf.identifier = 'username'
|
18
|
+
conf.password = 'password_crypt'
|
19
|
+
conf.salt = 'salty_salt
|
20
|
+
end
|
21
21
|
|
22
22
|
When creating/updating a record you have access to *password* accessor.
|
23
23
|
|
@@ -73,10 +73,10 @@ Authenticating Multiple Models
|
|
73
73
|
==============================
|
74
74
|
Yes, you can do that too. Let's assume you also want to authenticate admins that don't have email addresses, but have usernames.
|
75
75
|
|
76
|
-
LetMeIn.
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
LetMeIn.configure do |conf|
|
77
|
+
conf.models = ['User', 'Admin']
|
78
|
+
conf.identifier = ['email', 'username']
|
79
|
+
end
|
80
80
|
|
81
81
|
Bam! You're done. Now you have an AdminSession object that will use *username* and *password* to authenticate.
|
82
82
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/letmein.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{letmein}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-10}
|
13
13
|
s.description = %q{minimalistic authentication}
|
14
14
|
s.email = %q{oleg@khabarov.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.homepage = %q{http://github.com/GBH/letmein}
|
31
31
|
s.licenses = ["MIT"]
|
32
32
|
s.require_paths = ["lib"]
|
33
|
-
s.rubygems_version = %q{1.
|
33
|
+
s.rubygems_version = %q{1.6.2}
|
34
34
|
s.summary = %q{minimalistic authentication}
|
35
35
|
s.test_files = [
|
36
36
|
"test/letmein_test.rb"
|
data/lib/letmein.rb
CHANGED
@@ -98,7 +98,7 @@ module LetMeIn
|
|
98
98
|
p = LetMeIn.accessor(:password, LetMeIn.config.models.index(m))
|
99
99
|
s = LetMeIn.accessor(:password, LetMeIn.config.models.index(m))
|
100
100
|
object = m.constantize.send("find_by_#{i}", self.identifier)
|
101
|
-
self.authenticated_object = if object && object.send(p) == BCrypt::Engine.hash_secret(self.password, object.send(s))
|
101
|
+
self.authenticated_object = if object && !object.send(p).blank? && object.send(p) == BCrypt::Engine.hash_secret(self.password, object.send(s))
|
102
102
|
object
|
103
103
|
else
|
104
104
|
errors.add :base, 'Failed to authenticate'
|
data/test/letmein_test.rb
CHANGED
@@ -165,4 +165,15 @@ class LetMeInTest < Test::Unit::TestCase
|
|
165
165
|
end
|
166
166
|
assert_equal nil, session.authenticated_object
|
167
167
|
end
|
168
|
+
|
169
|
+
def test_session_authentication_on_blank_object
|
170
|
+
user = User.create!(:email => 'test@test.test')
|
171
|
+
session = UserSession.new(:email => 'test@test.test', :password => 'pass')
|
172
|
+
begin
|
173
|
+
session.save!
|
174
|
+
rescue LetMeIn::Error => e
|
175
|
+
assert_equal 'Failed to authenticate', e.to_s
|
176
|
+
end
|
177
|
+
assert_equal nil, session.authenticated_object
|
178
|
+
end
|
168
179
|
end
|
metadata
CHANGED
@@ -1,71 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: letmein
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Oleg Khabarov
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-10 00:00:00.000000000 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &70220938849600 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *70220938849600
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
27
|
name: bcrypt-ruby
|
28
|
-
requirement: &
|
28
|
+
requirement: &70220938849040 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *70220938849040
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70220938848460 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
|
-
requirements:
|
41
|
+
requirements:
|
42
42
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
43
|
+
- !ruby/object:Gem::Version
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *70220938848460
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &70220938847900 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
|
-
requirements:
|
52
|
+
requirements:
|
53
53
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
54
|
+
- !ruby/object:Gem::Version
|
55
55
|
version: 1.5.2
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70220938847900
|
59
59
|
description: minimalistic authentication
|
60
60
|
email: oleg@khabarov.ca
|
61
61
|
executables: []
|
62
|
-
|
63
62
|
extensions: []
|
64
|
-
|
65
|
-
extra_rdoc_files:
|
63
|
+
extra_rdoc_files:
|
66
64
|
- LICENSE
|
67
65
|
- README.md
|
68
|
-
files:
|
66
|
+
files:
|
69
67
|
- Gemfile
|
70
68
|
- Gemfile.lock
|
71
69
|
- LICENSE
|
@@ -75,35 +73,34 @@ files:
|
|
75
73
|
- letmein.gemspec
|
76
74
|
- lib/letmein.rb
|
77
75
|
- test/letmein_test.rb
|
76
|
+
has_rdoc: true
|
78
77
|
homepage: http://github.com/GBH/letmein
|
79
|
-
licenses:
|
78
|
+
licenses:
|
80
79
|
- MIT
|
81
80
|
post_install_message:
|
82
81
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
82
|
+
require_paths:
|
85
83
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
85
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
segments:
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
segments:
|
93
91
|
- 0
|
94
|
-
|
95
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
hash: 2973203238153488042
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
94
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version:
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
101
99
|
requirements: []
|
102
|
-
|
103
100
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.6.2
|
105
102
|
signing_key:
|
106
103
|
specification_version: 3
|
107
104
|
summary: minimalistic authentication
|
108
|
-
test_files:
|
105
|
+
test_files:
|
109
106
|
- test/letmein_test.rb
|