github-ldap 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5ecee7518b9ae2fdedb3c08c9c4b08e583543b1
4
- data.tar.gz: 9ba97e83307141282fafc3363e163c6eab0102e7
3
+ metadata.gz: c2875d8763d34a8f62c3a4ae77dc9cc054b29fdc
4
+ data.tar.gz: fb968ff1b0ed9276f7a5586b38487387c8f079a9
5
5
  SHA512:
6
- metadata.gz: daebbb8c5c0903dd0185893c3ac7f71c0701d5db0625c6e20f26b38e48519933aa65128cf6166893a57f1fb3c02cc456a03c76bb220d765f2bc6da02d5e748f8
7
- data.tar.gz: c4704da31546a9d34eb40ec0d79cf4062a9a19bae41c6580d33f58811dcb856eeb57665942fce43879dfecaa0a9afe59d3ec718d3db51eedae2e90ef5c6086b9
6
+ metadata.gz: a679ac3db436a73260c120ff3504880ae948b3b6339aa20e72e90b7df51df3e983c9f39ca70dca1fc2ee6d9e8ee4b4f034c9c2f2140af94f67dc7e0dfbf582bd
7
+ data.tar.gz: 6bc82a3b3cc07c91c12438f8fe9ada80419a21aceeba5bb0c8034c5e3c3e4305c2067130969d41b6f5ecfe1bd5c22529a7b7880e165f6e9f6257fd0cd2f49a43
data/github-ldap.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "github-ldap"
5
- spec.version = "1.1.3"
5
+ spec.version = "1.1.4"
6
6
  spec.authors = ["David Calavera"]
7
7
  spec.email = ["david.calavera@gmail.com"]
8
8
  spec.description = %q{Ldap authentication for humans}
@@ -137,7 +137,10 @@ module GitHub
137
137
  options[:ignore_server_caps] ||= true
138
138
  options[:paged_searches_supported] ||= true
139
139
 
140
- Array(@ldap.search(options))
140
+ rs = @ldap.search(options)
141
+ return [] if rs == false
142
+
143
+ Array(rs)
141
144
  end
142
145
 
143
146
  # Provide a meaningful result after a protocol operation (for example,
@@ -21,32 +21,18 @@ module GitHub
21
21
  #
22
22
  # Returns an array with all the member entries.
23
23
  def members
24
- groups, members = groups_and_members
25
- results = members
26
-
27
- cache = load_cache(groups)
28
-
29
- loop_cached_groups(groups, cache) do |_, users|
30
- results.concat users
31
- end
32
-
33
- results.uniq {|m| m.dn }
24
+ return @all_members if @all_members
25
+ group_and_member_entries
26
+ @all_members
34
27
  end
35
28
 
36
29
  # Public - Get all the subgroups from a group recursively.
37
30
  #
38
31
  # Returns an array with all the subgroup entries.
39
32
  def subgroups
40
- groups, _ = groups_and_members
41
- results = groups
42
-
43
- cache = load_cache(groups)
44
-
45
- loop_cached_groups(groups, cache) do |subgroups, _|
46
- results.concat subgroups
47
- end
48
-
49
- results
33
+ return @all_groups if @all_groups
34
+ group_and_member_entries
35
+ @all_groups
50
36
  end
51
37
 
52
38
  # Public - Check if a user dn is included in the members of this group and its subgroups.
@@ -119,6 +105,26 @@ module GitHub
119
105
  def groups_and_members
120
106
  member_entries.partition {|e| group?(e[:objectclass])}
121
107
  end
108
+
109
+ # Internal - Inspect the ldap server searching for group and member entries.
110
+ #
111
+ # Returns two arrays, the first one with subgroups and the second one with users.
112
+ def group_and_member_entries
113
+ groups, members = groups_and_members
114
+ @all_members = members
115
+ @all_groups = groups
116
+
117
+ cache = load_cache(groups)
118
+
119
+ loop_cached_groups(groups, cache) do |subgroups, users|
120
+ @all_groups.concat subgroups
121
+ @all_members.concat users
122
+ end
123
+
124
+ @all_members.uniq! {|m| m.dn }
125
+
126
+ [@all_groups, @all_members]
127
+ end
122
128
  end
123
129
  end
124
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Calavera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ldap