activeldap 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.textile +5 -3
- data/doc/text/development.textile +8 -4
- data/doc/text/news.textile +14 -0
- data/doc/text/tutorial.textile +6 -1
- data/lib/active_ldap.rb +1 -1
- data/lib/active_ldap/base.rb +0 -7
- data/lib/active_ldap/persistence.rb +11 -0
- data/lib/active_ldap/user_password.rb +13 -7
- data/test/test_user_password.rb +23 -16
- metadata +8 -10
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -7,8 +7,8 @@ A ruby library for object-oriented LDAP interface.
|
|
7
7
|
|
8
8
|
h2. Description
|
9
9
|
|
10
|
-
'ActiveLdap' is a ruby
|
11
|
-
|
10
|
+
'ActiveLdap' is a ruby library which provides a clean
|
11
|
+
objected oriented interface to LDAP library. It was
|
12
12
|
inspired by ActivRecord. This is not nearly as clean or as
|
13
13
|
flexible as ActiveRecord, but it is still trivial to define
|
14
14
|
new objects and manipulate them with minimal difficulty.
|
@@ -45,7 +45,7 @@ h2. Notes
|
|
45
45
|
|
46
46
|
h2. Rails
|
47
47
|
|
48
|
-
See "Rails":
|
48
|
+
See "Rails":file.rails.html page for Rails integration.
|
49
49
|
|
50
50
|
h2. Licence
|
51
51
|
|
@@ -135,3 +135,5 @@ list, please point out.
|
|
135
135
|
* rbq: A bug report.
|
136
136
|
* Narihiro Nakamura: Rails 3 support.
|
137
137
|
* Hidetoshi Yoshimoto: Rails 3 support.
|
138
|
+
* warden: A bug report.
|
139
|
+
* bklier: A bug fix.
|
@@ -32,10 +32,9 @@ Here is design about Rails 3 support.
|
|
32
32
|
|
33
33
|
h3. must
|
34
34
|
|
35
|
-
* We
|
36
|
-
|
37
|
-
|
38
|
-
for including ActiveLdap in a Rails 3 project is correct.
|
35
|
+
* We add active_ldap/test_help.rb to support ActiveLdap fixture.
|
36
|
+
We don't write same codes into test_helper.rb like
|
37
|
+
http://ruby-activeldap.rubyforge.org/activeldap-fabrication/en/#Install
|
39
38
|
|
40
39
|
h3. may
|
41
40
|
|
@@ -44,7 +43,12 @@ h3. may
|
|
44
43
|
* We support OmniAuth. (instead of Warden)
|
45
44
|
|
46
45
|
h3. DONE
|
46
|
+
|
47
47
|
* We don't support Rails 3.0.x.
|
48
48
|
* We provide active_ldap/railtie to initialize ActiveLdap.
|
49
49
|
* We remove ActiveRecord dependency.
|
50
50
|
* We depend on ActiveModel instead of ActiveRecord.
|
51
|
+
* We target to Rails 3.1.0. (Yes, it's not released yet
|
52
|
+
but it will be released before we support Rails 3.x.)
|
53
|
+
* We update the documentation and ensure that the procedure
|
54
|
+
for including ActiveLdap in a Rails 3 project is correct.
|
data/doc/text/news.textile
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
h1. News
|
2
2
|
|
3
|
+
h2(#3-1-1). 3.1.1: 2011-11-03
|
4
|
+
|
5
|
+
* Supported Rails 3.1.1.
|
6
|
+
* [GitHub:#9] Fixed a typo in document. [warden]
|
7
|
+
* [GitHub:#11] Added persisted?. [bklier]
|
8
|
+
* [GitHub:#16] Supported 4 or more bytes salt for SSHA and SMD5.
|
9
|
+
[Alex Tomlins]
|
10
|
+
|
11
|
+
h3. Thanks
|
12
|
+
|
13
|
+
* warden
|
14
|
+
* bklier
|
15
|
+
* Alex Tomlins
|
16
|
+
|
3
17
|
h2(#3-1-0). 3.1.0: 2011-07-09
|
4
18
|
|
5
19
|
* Supported Rails 3.1.0.rc4.
|
data/doc/text/tutorial.textile
CHANGED
@@ -49,6 +49,7 @@ h3. Installation
|
|
49
49
|
Assuming all the requirements are installed, you can install by gem.
|
50
50
|
|
51
51
|
<pre>
|
52
|
+
!!!plain
|
52
53
|
# gem install activeldap
|
53
54
|
</pre>
|
54
55
|
|
@@ -154,6 +155,7 @@ As you can see, this method is used for defining how this class maps in to LDAP.
|
|
154
155
|
my LDAP tree looks something like this:
|
155
156
|
|
156
157
|
<pre>
|
158
|
+
!!!plain
|
157
159
|
* dc=dataspill,dc=org
|
158
160
|
|- ou=People,dc=dataspill,dc=org
|
159
161
|
|+ ou=Groups,dc=dataspill,dc=org
|
@@ -172,6 +174,7 @@ as the beginning of the distinguished name.
|
|
172
174
|
Just for clarity, here's how the arguments map out:
|
173
175
|
|
174
176
|
<pre>
|
177
|
+
!!!plain
|
175
178
|
cn=develop,ou=Groups,dc=dataspill,dc=org
|
176
179
|
^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
|
177
180
|
:dn_attribute | |
|
@@ -213,6 +216,7 @@ tying objects together across the LDAP tree. Often, user objects will be
|
|
213
216
|
members of, or belong_to, Group objects.
|
214
217
|
|
215
218
|
<pre>
|
219
|
+
!!!plain
|
216
220
|
* dc=dataspill,dc=org
|
217
221
|
|+ ou=People,dc=dataspill,dc=org
|
218
222
|
\
|
@@ -589,7 +593,8 @@ h4. Setting up
|
|
589
593
|
Create directory for scripts.
|
590
594
|
|
591
595
|
<pre>
|
592
|
-
|
596
|
+
!!!plain
|
597
|
+
% mkdir -p ldapadmin/objects
|
593
598
|
</pre>
|
594
599
|
|
595
600
|
In ldapadmin/objects/ create the file user.rb:
|
data/lib/active_ldap.rb
CHANGED
data/lib/active_ldap/base.rb
CHANGED
@@ -755,13 +755,6 @@ module ActiveLdap
|
|
755
755
|
end
|
756
756
|
alias_method(:exists?, :exist?)
|
757
757
|
|
758
|
-
# new_entry?
|
759
|
-
#
|
760
|
-
# Return whether the entry is new entry in LDAP or not
|
761
|
-
def new_entry?
|
762
|
-
@new_entry
|
763
|
-
end
|
764
|
-
|
765
758
|
# dn
|
766
759
|
#
|
767
760
|
# Return the authoritative dn
|
@@ -1,5 +1,16 @@
|
|
1
1
|
module ActiveLdap
|
2
2
|
module Persistence
|
3
|
+
# new_entry?
|
4
|
+
#
|
5
|
+
# Return whether the entry is new entry in LDAP or not
|
6
|
+
def new_entry?
|
7
|
+
@new_entry
|
8
|
+
end
|
9
|
+
|
10
|
+
# Return whether the entry is saved entry or not.
|
11
|
+
def persisted?
|
12
|
+
not new_entry?
|
13
|
+
end
|
3
14
|
|
4
15
|
# destroy
|
5
16
|
#
|
@@ -8,7 +8,8 @@ module ActiveLdap
|
|
8
8
|
module_function
|
9
9
|
def valid?(password, hashed_password)
|
10
10
|
unless /^\{([A-Z][A-Z\d]+)\}/ =~ hashed_password
|
11
|
-
|
11
|
+
# Plain text password
|
12
|
+
return hashed_password == password
|
12
13
|
end
|
13
14
|
type = $1
|
14
15
|
hashed_password_without_type = $POSTMATCH
|
@@ -48,8 +49,8 @@ module ActiveLdap
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def smd5(password, salt=nil)
|
51
|
-
if salt and salt.size
|
52
|
-
raise ArgumentError, _("salt size must be
|
52
|
+
if salt and salt.size < 4
|
53
|
+
raise ArgumentError, _("salt size must be >= 4: %s") % salt.inspect
|
53
54
|
end
|
54
55
|
salt ||= Salt.generate(4)
|
55
56
|
md5_hash_with_salt = "#{Digest::MD5.digest(password + salt)}#{salt}"
|
@@ -57,7 +58,7 @@ module ActiveLdap
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def extract_salt_for_smd5(smd5ed_password)
|
60
|
-
|
61
|
+
extract_salt_at_pos(smd5ed_password, 16)
|
61
62
|
end
|
62
63
|
|
63
64
|
def sha(password)
|
@@ -65,8 +66,8 @@ module ActiveLdap
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def ssha(password, salt=nil)
|
68
|
-
if salt and salt.size
|
69
|
-
raise ArgumentError, _("salt size must be
|
69
|
+
if salt and salt.size < 4
|
70
|
+
raise ArgumentError, _("salt size must be >= 4: %s") % salt.inspect
|
70
71
|
end
|
71
72
|
salt ||= Salt.generate(4)
|
72
73
|
sha1_hash_with_salt = "#{Digest::SHA1.digest(password + salt)}#{salt}"
|
@@ -74,7 +75,12 @@ module ActiveLdap
|
|
74
75
|
end
|
75
76
|
|
76
77
|
def extract_salt_for_ssha(sshaed_password)
|
77
|
-
|
78
|
+
extract_salt_at_pos(sshaed_password, 20)
|
79
|
+
end
|
80
|
+
|
81
|
+
def extract_salt_at_pos(hashed_password, position)
|
82
|
+
salt = Base64.decode64(hashed_password)[position..-1]
|
83
|
+
salt == '' ? nil : salt
|
78
84
|
end
|
79
85
|
|
80
86
|
module Salt
|
data/test/test_user_password.rb
CHANGED
@@ -5,11 +5,20 @@ class TestUserPassword < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
priority :normal
|
7
7
|
def test_valid?
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
{
|
9
|
+
"{CRYPT}.yNLaKqtwQbnY" => 'wibble', #CRYPT
|
10
|
+
"{MD5}DRB9CfW75Ayt495ccenptw==" => 'letmein', #MD5
|
11
|
+
"{SMD5}8L2iXJuazftLVHrAf7ptPFQIDaw=" => 'letmein', #SMD5 as generated by slappasswd (4 bytes of salt)
|
12
|
+
"{SMD5}kXibTNG+O98gaQtkugYcmSTiE+M2Z5TA" => 'letmein', #SMD5 as generated by Apache Directory Studio (8 bytes of salt)
|
13
|
+
"{SHA}t6h1/B6iKLkGEEG3zsS9PFKrPOM=" => 'letmein', #SHA
|
14
|
+
"{SSHA}YA87hc9/L/cCGR1HValcJb7a8AYxZXY4" => 'wibble', # SSHA as generated by slappasswd (4 bytes of salt)
|
15
|
+
"{SSHA}6J6Ios3l1panY9sm0+g9l3/jFz2kwOPrVA4+OA==" => 'letmein', # SSHA as generated by Apache Directory Studio (8 bytes of salt)
|
16
|
+
"letmein" => 'letmein', #Cleartext password
|
17
|
+
}.each do |hash, plain|
|
11
18
|
assert_send([ActiveLdap::UserPassword, :valid?,
|
12
|
-
|
19
|
+
plain, hash])
|
20
|
+
assert_not_send([ActiveLdap::UserPassword, :valid?,
|
21
|
+
"not#{plain}", hash])
|
13
22
|
end
|
14
23
|
end
|
15
24
|
|
@@ -51,12 +60,11 @@ class TestUserPassword < Test::Unit::TestCase
|
|
51
60
|
end
|
52
61
|
|
53
62
|
def test_extract_salt_for_smd5
|
54
|
-
assert_extract_salt(:smd5,
|
55
|
-
assert_extract_salt(:smd5,
|
56
|
-
assert_extract_salt(:smd5, nil, encode64("
|
57
|
-
assert_extract_salt(:smd5, nil, encode64("
|
58
|
-
assert_extract_salt(:smd5,
|
59
|
-
assert_extract_salt(:smd5, "BCDE", encode64("ABCDE"))
|
63
|
+
assert_extract_salt(:smd5, 'this', encode64("1234567890123456this"))
|
64
|
+
assert_extract_salt(:smd5, 'this is the salt', encode64("1234567890123456this is the salt"))
|
65
|
+
assert_extract_salt(:smd5, nil, encode64("123456789"))
|
66
|
+
assert_extract_salt(:smd5, nil, encode64("123456789012345"))
|
67
|
+
assert_extract_salt(:smd5, nil, encode64("1234567890123456"))
|
60
68
|
end
|
61
69
|
|
62
70
|
def test_sha
|
@@ -76,12 +84,11 @@ class TestUserPassword < Test::Unit::TestCase
|
|
76
84
|
end
|
77
85
|
|
78
86
|
def test_extract_salt_for_ssha
|
79
|
-
assert_extract_salt(:ssha,
|
80
|
-
assert_extract_salt(:ssha,
|
81
|
-
assert_extract_salt(:ssha, nil, encode64("
|
82
|
-
assert_extract_salt(:ssha, nil, encode64("
|
83
|
-
assert_extract_salt(:ssha,
|
84
|
-
assert_extract_salt(:ssha, "BCDE", encode64("ABCDE"))
|
87
|
+
assert_extract_salt(:ssha, 'this', encode64("12345678901234567890this"))
|
88
|
+
assert_extract_salt(:ssha, 'this is the salt', encode64("12345678901234567890this is the salt"))
|
89
|
+
assert_extract_salt(:ssha, nil, encode64("12345678901234"))
|
90
|
+
assert_extract_salt(:ssha, nil, encode64("1234567890123456789"))
|
91
|
+
assert_extract_salt(:ssha, nil, encode64("12345678901234567890"))
|
85
92
|
end
|
86
93
|
|
87
94
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 1
|
10
|
+
version: 3.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Will Drewry
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-11-03 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -24,14 +24,12 @@ dependencies:
|
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
27
|
+
hash: 3
|
28
28
|
segments:
|
29
29
|
- 3
|
30
30
|
- 1
|
31
31
|
- 0
|
32
|
-
|
33
|
-
- 4
|
34
|
-
version: 3.1.0.rc4
|
32
|
+
version: 3.1.0
|
35
33
|
name: activemodel
|
36
34
|
prerelease: false
|
37
35
|
type: :runtime
|
@@ -176,7 +174,7 @@ dependencies:
|
|
176
174
|
prerelease: false
|
177
175
|
type: :development
|
178
176
|
requirement: *id011
|
179
|
-
description: " 'ActiveLdap' is a ruby
|
177
|
+
description: " 'ActiveLdap' is a ruby library which provides a clean\n objected oriented interface to the Ruby/LDAP library. It was inspired\n by ActiveRecord. This is not nearly as clean or as flexible as\n ActiveRecord, but it is still trivial to define new objects and manipulate\n them with minimal difficulty.\n"
|
180
178
|
email:
|
181
179
|
- redpig@dataspill.org
|
182
180
|
- kou@cozmixng.org
|
@@ -345,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
343
|
requirements: []
|
346
344
|
|
347
345
|
rubyforge_project: ruby-activeldap
|
348
|
-
rubygems_version: 1.
|
346
|
+
rubygems_version: 1.8.10
|
349
347
|
signing_key:
|
350
348
|
specification_version: 3
|
351
349
|
summary: ActiveLdap is a object-oriented API to LDAP
|