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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem 'activemodel', '~> 3.1.0.rc4'
5
+ gem 'activemodel', '~> 3.1.0'
6
6
  gem 'locale'
7
7
  gem 'fast_gettext'
8
8
  gem 'gettext_i18n_rails'
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 extension library which provides a
11
- clean objected oriented interface to LDAP library. It was
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":files.rails.html page for Rails integration.
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 target to Rails 3.1.0. (Yes, it's not released yet
36
- but it will be released before we support Rails 3.x.)
37
- * We update the documentation and ensure that the procedure
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.
@@ -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.
@@ -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
- mkdir -p ldapadmin/objects
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
@@ -3,7 +3,7 @@ require "active_model"
3
3
  require "active_support/core_ext"
4
4
 
5
5
  module ActiveLdap
6
- VERSION = "3.1.0"
6
+ VERSION = "3.1.1"
7
7
  autoload :Command, "active_ldap/command"
8
8
  end
9
9
 
@@ -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
- raise ArgumentError, _("Invalid hashed password: %s") % hashed_password
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 != 4
52
- raise ArgumentError, _("salt size must be == 4: %s") % salt.inspect
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
- Base64.decode64(smd5ed_password)[-4, 4]
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 != 4
69
- raise ArgumentError, _("salt size must be == 4: %s") % salt.inspect
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
- extract_salt_for_smd5(sshaed_password)
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
@@ -5,11 +5,20 @@ class TestUserPassword < Test::Unit::TestCase
5
5
 
6
6
  priority :normal
7
7
  def test_valid?
8
- plain_password = "password"
9
- %w(crypt md5 smd5 sha ssha).each do |type|
10
- hashed_password = ActiveLdap::UserPassword.send(type, plain_password)
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
- plain_password, hashed_password])
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, nil, encode64(""))
55
- assert_extract_salt(:smd5, nil, encode64("1"))
56
- assert_extract_salt(:smd5, nil, encode64("12"))
57
- assert_extract_salt(:smd5, nil, encode64("123"))
58
- assert_extract_salt(:smd5, "ABCD", encode64("ABCD"))
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, nil, encode64(""))
80
- assert_extract_salt(:ssha, nil, encode64("1"))
81
- assert_extract_salt(:ssha, nil, encode64("12"))
82
- assert_extract_salt(:ssha, nil, encode64("123"))
83
- assert_extract_salt(:ssha, "ABCD", encode64("ABCD"))
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: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 0
10
- version: 3.1.0
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-07-09 00:00:00 Z
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: 15424109
27
+ hash: 3
28
28
  segments:
29
29
  - 3
30
30
  - 1
31
31
  - 0
32
- - rc
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 extension 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"
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.7.2
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