github-ldap 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/github-ldap.gemspec +1 -1
- data/lib/github/ldap/domain.rb +15 -6
- data/test/domain_test.rb +13 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -39,7 +39,7 @@ Initialize a new adapter using those required options:
|
|
39
39
|
ldap = GitHub::Ldap.new options
|
40
40
|
```
|
41
41
|
|
42
|
-
###
|
42
|
+
### Querying
|
43
43
|
|
44
44
|
Searches are performed against an individual domain base, so the first step is to get a new `GitHub::Ldap::Domain` object for the connection:
|
45
45
|
|
data/github-ldap.gemspec
CHANGED
data/lib/github/ldap/domain.rb
CHANGED
@@ -36,9 +36,7 @@ module GitHub
|
|
36
36
|
def groups(group_names)
|
37
37
|
filter = group_filter(group_names)
|
38
38
|
|
39
|
-
|
40
|
-
attributes: %w{ou cn dn sAMAccountName member},
|
41
|
-
filter: filter)
|
39
|
+
search(attributes: %w{ou cn dn sAMAccountName member}, filter: filter)
|
42
40
|
end
|
43
41
|
|
44
42
|
# List the groups that a user is member of.
|
@@ -51,9 +49,7 @@ module GitHub
|
|
51
49
|
or_filters = group_names.map {|g| Net::LDAP::Filter.eq("cn", g)}.reduce(:|)
|
52
50
|
member_filter = Net::LDAP::Filter.eq("member", user_dn) & or_filters
|
53
51
|
|
54
|
-
|
55
|
-
attributes: %w{ou cn dn sAMAccountName member},
|
56
|
-
filter: member_filter)
|
52
|
+
search(attributes: %w{ou cn dn sAMAccountName member}, filter: member_filter)
|
57
53
|
end
|
58
54
|
|
59
55
|
# Check if the user is include in any of the configured groups.
|
@@ -103,6 +99,19 @@ module GitHub
|
|
103
99
|
|
104
100
|
return user if user && is_member?(user.dn, group_names)
|
105
101
|
end
|
102
|
+
|
103
|
+
# Search entries using this domain as base.
|
104
|
+
#
|
105
|
+
# options: is a Hash with the options for the search.
|
106
|
+
# The base option is always overriden.
|
107
|
+
#
|
108
|
+
# Returns an array with the entries found.
|
109
|
+
# Returns nil if there are no entries.
|
110
|
+
def search(options)
|
111
|
+
options[:base] = @base_name
|
112
|
+
|
113
|
+
@connection.search(options)
|
114
|
+
end
|
106
115
|
end
|
107
116
|
end
|
108
117
|
end
|
data/test/domain_test.rb
CHANGED
@@ -87,5 +87,18 @@ class GitHubLdapDomainTest < Minitest::Test
|
|
87
87
|
assert_equal 1, groups.size
|
88
88
|
assert_equal 'cn=Enterprise,ou=Group,dc=github,dc=com', groups.first.dn
|
89
89
|
end
|
90
|
+
|
91
|
+
def test_search
|
92
|
+
assert 1, @domain.search(
|
93
|
+
attributes: %w(uid),
|
94
|
+
filter: Net::LDAP::Filter.eq('uid', 'calavera')).size
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_search_override_base_name
|
98
|
+
assert 1, @domain.search(
|
99
|
+
base: "this base name is incorrect",
|
100
|
+
attributes: %w(uid),
|
101
|
+
filter: Net::LDAP::Filter.eq('uid', 'calavera')).size
|
102
|
+
end
|
90
103
|
end
|
91
104
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ldap
|