ldap_groups_lookup 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -4
- data/README.md +31 -4
- data/lib/ldap_groups_lookup/configuration.rb +2 -2
- data/lib/ldap_groups_lookup/search.rb +1 -1
- data/lib/ldap_groups_lookup/version.rb +1 -1
- data/spec/fixtures/ldap_groups_lookup.yml.example +1 -1
- data/spec/lib/ldap_groups_lookup_spec.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7affc77773609169dc9b5bd910bd7c1d9e8a3e157f0c9f33e843dd626df735
|
4
|
+
data.tar.gz: 9b1c0bf677410247aec9634defcd67e5ade14ec40a86ad72d7ea59aae9dead55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f98193e36b4165186f6aaa6aeb99f213d71f84feb90391a231084d61395ea022fabdbe38031a8607ffd8c97cebf02420036a6ff0327cb2537a60ad17d49f7c7
|
7
|
+
data.tar.gz: 6d7456b672ec139e12c60a428c279cb02cd5bebaea54f25e02467a1b7663836057c352fa32baa1010d8999eef9ef0c47da7950a8a5ea195476dabeb2a30b93e3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -18,19 +18,17 @@ permissions:
|
|
18
18
|
|
19
19
|
jobs:
|
20
20
|
test:
|
21
|
-
|
22
21
|
runs-on: ubuntu-latest
|
23
22
|
strategy:
|
24
23
|
matrix:
|
25
|
-
ruby-version: ['2.7', '3.
|
26
|
-
|
24
|
+
ruby-version: ['2.7', '3.3']
|
27
25
|
steps:
|
28
26
|
- uses: actions/checkout@v4
|
29
27
|
- name: Set up Ruby
|
30
28
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
29
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
30
|
# uses: ruby/setup-ruby@v1
|
33
|
-
uses: ruby/setup-ruby@
|
31
|
+
uses: ruby/setup-ruby@v1
|
34
32
|
with:
|
35
33
|
ruby-version: ${{ matrix.ruby-version }}
|
36
34
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# IU LDAP Groups Lookup
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/ldap_groups_lookup.svg)](https://badge.fury.io/rb/ldap_groups_lookup)
|
2
3
|
|
3
4
|
## Usage
|
4
5
|
|
@@ -32,12 +33,37 @@ u.member_of_ldap_group?(['Some-Group'])
|
|
32
33
|
|
33
34
|
## Configuration
|
34
35
|
|
35
|
-
|
36
|
+
### Initializer
|
37
|
+
Create an initializer `config/initializers/ldap_groups_lookup.rb` that looks like:
|
38
|
+
```ruby
|
39
|
+
LDAPGroupsLookup.config = {
|
40
|
+
enabled: true,
|
41
|
+
config: { host: 'ads.example.net',
|
42
|
+
port: 636,
|
43
|
+
encryption: {
|
44
|
+
method: :simple_tls,
|
45
|
+
tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS,
|
46
|
+
},
|
47
|
+
auth: {
|
48
|
+
method: :simple,
|
49
|
+
username: "cn=example",
|
50
|
+
password: 'changeme',
|
51
|
+
}
|
52
|
+
},
|
53
|
+
tree: 'dc=ads,dc=example,dc=net',
|
54
|
+
account_ou: 'ou=Accounts',
|
55
|
+
group_ou: 'ou=Groups',
|
56
|
+
member_allowlist: ['OU=Groups']
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
### YAML
|
61
|
+
Alternatively, create a file `config/ldap_groups_lookup.yml` that looks like:
|
36
62
|
|
37
63
|
```yaml
|
38
64
|
:enabled: true
|
39
65
|
:host: ads.example.net
|
40
|
-
:port:
|
66
|
+
:port: 389
|
41
67
|
:auth:
|
42
68
|
:method: :simple
|
43
69
|
:username: example
|
@@ -45,6 +71,7 @@ Create a file `config/ldap_groups_lookup.yml` that looks like:
|
|
45
71
|
:tree: dc=ads,dc=example,dc=net
|
46
72
|
:account_ou: ou=Accounts
|
47
73
|
:group_ou: ou=Groups
|
48
|
-
:
|
74
|
+
:member_allowlist:
|
49
75
|
- OU=Groups
|
50
|
-
```
|
76
|
+
```
|
77
|
+
Note: The yaml style does not allow for easy configuration of some properties like tls_options or other auth methods.
|
@@ -57,7 +57,7 @@ module LDAPGroupsLookup
|
|
57
57
|
next if seen.include? g
|
58
58
|
seen << g
|
59
59
|
member_groups = members.collect do |mg|
|
60
|
-
dn_to_cn(mg) if
|
60
|
+
dn_to_cn(mg) if member_allowlist.empty? || member_allowlist.any? do |fil|
|
61
61
|
mg.include? fil
|
62
62
|
end
|
63
63
|
end
|
@@ -243,25 +243,25 @@ RSpec.describe LDAPGroupsLookup do
|
|
243
243
|
hash_including(filter: Net::LDAP::Filter.equals('cn', 'Nested-Group'),
|
244
244
|
attributes: ['member;range=1-*'])).and_return([@nested_group_page_2])
|
245
245
|
end
|
246
|
-
context 'when the group is
|
246
|
+
context 'when the group is allowlisted' do
|
247
247
|
before do
|
248
|
-
allow(LDAPGroupsLookup).to receive(:
|
248
|
+
allow(LDAPGroupsLookup).to receive(:member_allowlist).and_return(['OU=Groups'])
|
249
249
|
end
|
250
250
|
it 'should return true' do
|
251
251
|
expect(user.member_of_ldap_group?('Top-Group')).to eq(true)
|
252
252
|
end
|
253
253
|
end
|
254
|
-
context 'when the
|
254
|
+
context 'when the allowlist is empty' do
|
255
255
|
before do
|
256
|
-
allow(LDAPGroupsLookup).to receive(:
|
256
|
+
allow(LDAPGroupsLookup).to receive(:member_allowlist).and_return([])
|
257
257
|
end
|
258
|
-
it 'should return true (
|
258
|
+
it 'should return true (allowlisting is disabled)' do
|
259
259
|
expect(user.member_of_ldap_group?('Top-Group')).to eq(true)
|
260
260
|
end
|
261
261
|
end
|
262
|
-
context 'when the group is not
|
262
|
+
context 'when the group is not allowlisted' do
|
263
263
|
before do
|
264
|
-
allow(LDAPGroupsLookup).to receive(:
|
264
|
+
allow(LDAPGroupsLookup).to receive(:member_allowlist).and_return(['OU=Not-A-Match'])
|
265
265
|
end
|
266
266
|
it 'should return false' do
|
267
267
|
expect(user.member_of_ldap_group?('Top-Group')).to eq(false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldap_groups_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Ploshay
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-11-
|
13
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: net-ldap
|