ldap_groups_lookup 0.7.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +38 -0
- data/README.md +23 -2
- data/ldap_groups_lookup.gemspec +1 -0
- data/lib/ldap_groups_lookup/configuration.rb +6 -2
- data/lib/ldap_groups_lookup/version.rb +1 -1
- data/spec/fixtures/ldap_groups_lookup.yml.example +1 -0
- data/spec/lib/ldap_groups_lookup_spec.rb +10 -1
- metadata +9 -9
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87571e7afbf4949aab968013b93e8aef388659e5196346d1b1d70cf9bdfa34ed
|
4
|
+
data.tar.gz: 4ffba8461216819da410a872d463fe8a49e73495c8f7d4ca3e96aeff6e81123d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009ec292b50df3a270bca37bdf49ce1dfa3cc82c21dd0efb9764743489d5ec16cf983af3446019aed0a58923d174abb0e2e8af2122a583b11e633ba210d37cfe'
|
7
|
+
data.tar.gz: 9ac84ea34432eb8430793031d9a4f45e34eb06cba597e59d0f8c7978af13608cdb25fe91d4e99fc236cbeddb42ea2f03b95a0166359d0a9f3fec1012aaba5471
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.7', '3.2']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v4
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# IU LDAP Groups Lookup
|
2
2
|
|
3
|
+
## Usage
|
4
|
+
|
3
5
|
Adds an LDAPGroupsLookup that can be included in a a class to provide an #ldap_groups instance method:
|
4
6
|
|
5
|
-
```
|
7
|
+
```ruby
|
6
8
|
class User
|
7
9
|
attr_accessor :ldap_lookup_key
|
8
10
|
include LDAPGroupsLookup::Behavior
|
@@ -16,7 +18,7 @@ u.member_of_ldap_group?(['Some-Group'])
|
|
16
18
|
|
17
19
|
The LDAP search will be run by the value of #ldap_lookup_key, so your instance object must provide that through some means:
|
18
20
|
|
19
|
-
```
|
21
|
+
```ruby
|
20
22
|
class User < ActiveRecord::Base
|
21
23
|
validates :username, presence: true, uniqueness: true
|
22
24
|
alias_attribute :ldap_lookup_key, :username
|
@@ -27,3 +29,22 @@ u = User.find_by(username: 'some_username')
|
|
27
29
|
u.ldap_groups
|
28
30
|
u.member_of_ldap_group?(['Some-Group'])
|
29
31
|
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
Create a file `config/ldap_groups_lookup.yml` that looks like:
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
:enabled: true
|
39
|
+
:host: ads.example.net
|
40
|
+
:port: 636
|
41
|
+
:auth:
|
42
|
+
:method: :simple
|
43
|
+
:username: example
|
44
|
+
:password: changeme
|
45
|
+
:tree: dc=ads,dc=example,dc=net
|
46
|
+
:account_ou: ou=Accounts
|
47
|
+
:group_ou: ou=Groups
|
48
|
+
:member_whitelist:
|
49
|
+
- OU=Groups
|
50
|
+
```
|
data/ldap_groups_lookup.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
gem.required_ruby_version = '>= 2.3.0'
|
19
|
+
gem.metadata = { "rubygems_mfa_required" => "true" }
|
19
20
|
|
20
21
|
gem.add_dependency 'net-ldap'
|
21
22
|
gem.add_development_dependency 'rake'
|
@@ -9,7 +9,11 @@ module LDAPGroupsLookup
|
|
9
9
|
def service
|
10
10
|
return nil if config[:enabled] == false
|
11
11
|
if @ldap_service.nil?
|
12
|
-
|
12
|
+
if config[:config].is_a? Hash
|
13
|
+
@ldap_service = Net::LDAP.new(**config[:config])
|
14
|
+
else
|
15
|
+
@ldap_service = Net::LDAP.new(host: config[:host], port: config[:port] || Net::LDAP::DefaultPort, auth: config[:auth])
|
16
|
+
end
|
13
17
|
raise Net::LDAP::Error unless @ldap_service.bind
|
14
18
|
end
|
15
19
|
@ldap_service
|
@@ -55,7 +59,7 @@ module LDAPGroupsLookup
|
|
55
59
|
if value.nil? || value.is_a?(Hash)
|
56
60
|
@config = value
|
57
61
|
elsif value.is_a?(String)
|
58
|
-
if File.
|
62
|
+
if File.exist?(value)
|
59
63
|
@config = YAML.load(ERB.new(File.read(value)).result)
|
60
64
|
else
|
61
65
|
@config = { enabled: false }
|
@@ -28,7 +28,7 @@ RSpec.describe LDAPGroupsLookup do
|
|
28
28
|
context 'when the config file is missing' do
|
29
29
|
before do
|
30
30
|
allow(LDAPGroupsLookup).to receive(:config).and_call_original
|
31
|
-
expect(File).to receive(:
|
31
|
+
expect(File).to receive(:exist?).with(/config\/ldap_groups_lookup\.yml$/)
|
32
32
|
end
|
33
33
|
it 'should return nil' do
|
34
34
|
expect(LDAPGroupsLookup.service).to be_nil
|
@@ -61,6 +61,15 @@ RSpec.describe LDAPGroupsLookup do
|
|
61
61
|
it 'should return a Net::LDAP instance' do
|
62
62
|
expect(LDAPGroupsLookup.service).to be_an_instance_of(Net::LDAP)
|
63
63
|
end
|
64
|
+
|
65
|
+
context 'when the :config key is set' do
|
66
|
+
let(:config_hash) { { host: 'localhost', port: 636, encryption: { method: :simple_tls, tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS } } }
|
67
|
+
before { config[:config] = config_hash }
|
68
|
+
it 'uses that config' do
|
69
|
+
expect(Net::LDAP).to receive(:new).with(config_hash).and_call_original
|
70
|
+
expect(LDAPGroupsLookup.service).to be_an_instance_of(Net::LDAP)
|
71
|
+
end
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
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.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Ploshay
|
8
8
|
- Daniel Pierce
|
9
9
|
- Avalon Media System
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: net-ldap
|
@@ -77,9 +77,9 @@ executables: []
|
|
77
77
|
extensions: []
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
|
+
- ".github/workflows/ruby.yml"
|
80
81
|
- ".gitignore"
|
81
82
|
- ".rspec"
|
82
|
-
- ".travis.yml"
|
83
83
|
- Gemfile
|
84
84
|
- LICENSE
|
85
85
|
- README.md
|
@@ -95,8 +95,9 @@ files:
|
|
95
95
|
- spec/spec_helper.rb
|
96
96
|
homepage: http://github.com/IUBLibTech/ldap_groups_lookup
|
97
97
|
licenses: []
|
98
|
-
metadata:
|
99
|
-
|
98
|
+
metadata:
|
99
|
+
rubygems_mfa_required: 'true'
|
100
|
+
post_install_message:
|
100
101
|
rdoc_options: []
|
101
102
|
require_paths:
|
102
103
|
- lib
|
@@ -111,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
- !ruby/object:Gem::Version
|
112
113
|
version: '0'
|
113
114
|
requirements: []
|
114
|
-
|
115
|
-
|
116
|
-
signing_key:
|
115
|
+
rubygems_version: 3.5.17
|
116
|
+
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Provides easy access to the list of LDAP groups a username is a member of.
|
119
119
|
test_files:
|