adap 0.1.10 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63f5d0cc91cadfe37b62c84602420c11adb34b8e80f3f60ff51a767e75621788
4
- data.tar.gz: 9780fc3c0145805bcb042d5c4df8018b6d8df5ab824b1fd1c5a74e5103934627
3
+ metadata.gz: '0027496e73b5ac4ad67838975ca7876a4d9efed7b64de41733b1ef85b591f893'
4
+ data.tar.gz: 6fcaf2a2f8506dff5c606593f2565ee5b853ff672eaecd7d9e2a27b41108431d
5
5
  SHA512:
6
- metadata.gz: c0fa71f2e0ba6edc95c710ee05e242f4eb1af904dcfa5a5157bd58afa57c0f4ce3afe7a76a408afbd0e0b33f2d559204f7b1215015f7e26517e92b089cd2610a
7
- data.tar.gz: dd285ad4b31c0c4d730d200ac98e0b419ba65ace520218f99945e70df50a2841c498a5074a28537d11e5ae034eaf33a4b728c25629be562a06396c76efab3634
6
+ metadata.gz: fa4f5affabb9498f6d0f3a2802807fedfdb975870102fb16ba67fc9e0d9ff69c0b17cf3c1c5baf5c3b847f6aabd149f3114f778f8f45683fe0d81d6390118ba3
7
+ data.tar.gz: 9e19e2633f89514187f1f5a5472f62933f89d604399a3aafb56b674735f4784f58e2d7459c2160877ec800c3a966f84e27dfc5c6f6831f6fd4e4af62a285dff5
@@ -0,0 +1,48 @@
1
+ # To run workflow
2
+
3
+ # GitHub Actions
4
+ ## For unit testing
5
+ When you push to any branch "master", "develop" or merge a PR to "master", the unit tests will run automatically.
6
+ Please check the progress in the Actions tab.
7
+
8
+
9
+ ## For release (interactively)
10
+ First, you need to modify a version in `./lib/adap/version.py`.
11
+ Then, you can run the following command to trigger the release workflow.
12
+
13
+ ```
14
+ $ vim lib/adap/version.rb
15
+ -> Update VERSION
16
+ ```
17
+
18
+ Then create a commit and push it and create a PR.
19
+ After it was merged, you can run the following command to trigger the release workflow.
20
+
21
+ ```
22
+ $ gh workflow run
23
+ ? Select a workflow [Use arrows to move, type to filter]
24
+ > Ruby (release.yml) // <- Select "Ruby (release.yml)"
25
+ Ruby (ruby.yml)
26
+ Dependabot Updates (dependabot-updates)
27
+
28
+ ? otp (required) // <- Input the OTP code
29
+ ```
30
+
31
+
32
+
33
+ ```
34
+ $ gh run list --workflow=release.yml
35
+ STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE
36
+ * Ruby Ruby master workflow_dispatch 12673039585 10s less than a minute ago
37
+ ```
38
+
39
+
40
+ ## For release (non-interactively)
41
+ You can also trigger the release workflow non-interactively.
42
+
43
+ ```
44
+ gh workflow run release.yml --ref=master --field otp=123456
45
+ ```
46
+
47
+ `--field otp=123456` is required to input the OTP code.
48
+ You have to change `123456` to the actual OTP code.
data/lib/adap/adap.rb CHANGED
@@ -19,8 +19,8 @@ class Adap
19
19
  def initialize(params)
20
20
  raise "Initialize Adap was failed. params must not be nil" if params == nil
21
21
 
22
- [:ad_host, :ad_binddn, :ad_user_basedn, :ad_group_basedn, :ldap_host, :ldap_binddn, :ldap_user_basedn, :ldap_group_basedn].each { |k|
23
- raise 'Adap requires keys in params ":ad_host", ":ad_binddn", ":ad_user_basedn", ":ad_group_basedn", ":ldap_host", ":ldap_binddn", ":ldap_user_basedn", ":ldap_group_basedn"' if !params.key?(k)
22
+ [:ad_host, :ad_bind_dn, :ad_user_base_dn, :ad_group_base_dn, :ldap_host, :ldap_bind_dn, :ldap_user_base_dn, :ldap_group_base_dn].each { |k|
23
+ raise 'Adap requires keys in params ":ad_host", ":ad_bind_dn", ":ad_user_base_dn", ":ad_group_base_dn", ":ldap_host", ":ldap_bind_dn", ":ldap_user_base_dn", ":ldap_group_base_dn"' if !params.key?(k)
24
24
  }
25
25
 
26
26
  # List of attributes for user in AD
@@ -41,17 +41,17 @@ class Adap
41
41
 
42
42
  @ad_host = params[:ad_host]
43
43
  @ad_port = (params[:ad_port] ? params[:ad_port] : 389)
44
- @ad_binddn = params[:ad_binddn]
45
- @ad_user_basedn = params[:ad_user_basedn]
46
- @ad_group_basedn = params[:ad_group_basedn]
47
- @ad_auth = (params.has_key?(:ad_password) ? { :method => :simple, :username => @ad_binddn, :password => params[:ad_password] } : nil)
44
+ @ad_bind_dn = params[:ad_bind_dn]
45
+ @ad_user_base_dn = params[:ad_user_base_dn]
46
+ @ad_group_base_dn = params[:ad_group_base_dn]
47
+ @ad_auth = (params.has_key?(:ad_password) ? { :method => :simple, :username => @ad_bind_dn, :password => params[:ad_password] } : nil)
48
48
  @ldap_host = params[:ldap_host]
49
49
  @ldap_port = (params[:ldap_port] ? params[:ldap_port] : 389)
50
- @ldap_binddn = params[:ldap_binddn]
51
- @ldap_basedn = params[:ldap_basedn]
52
- @ldap_user_basedn = params[:ldap_user_basedn]
53
- @ldap_group_basedn = params[:ldap_group_basedn]
54
- @ldap_auth = (params.has_key?(:ldap_password) ? { :method => :simple, :username => @ldap_binddn, :password => params[:ldap_password] } : nil )
50
+ @ldap_bind_dn = params[:ldap_bind_dn]
51
+ @ldap_base_dn = params[:ldap_base_dn]
52
+ @ldap_user_base_dn = params[:ldap_user_base_dn]
53
+ @ldap_group_base_dn = params[:ldap_group_base_dn]
54
+ @ldap_auth = (params.has_key?(:ldap_password) ? { :method => :simple, :username => @ldap_bind_dn, :password => params[:ldap_password] } : nil )
55
55
 
56
56
  # A password-hash algorithm to sync to the LDAP.
57
57
  # Popular LDAP products like Open LDAP usually supports md5({MD5}), sha1({SHA}) and ssha({SSHA}) algorithms.
@@ -101,11 +101,11 @@ class Adap
101
101
  end
102
102
 
103
103
  def get_ad_user_dn(username)
104
- "CN=#{username},#{@ad_user_basedn}"
104
+ "CN=#{username},#{@ad_user_base_dn}"
105
105
  end
106
106
 
107
107
  def get_ldap_user_dn(username)
108
- "uid=#{username},#{@ldap_user_basedn}"
108
+ "uid=#{username},#{@ldap_user_base_dn}"
109
109
  end
110
110
 
111
111
  def create_ldap_attributes(ad_entry)
@@ -342,26 +342,26 @@ class Adap
342
342
  # Creating AD ldapsearch filter
343
343
 
344
344
  ad_filter = if primary_gid_number == nil then
345
- # TODO: Searching with filter `objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_basedn}` is more accureate.
345
+ # TODO: Searching with filter `objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_base_dn}` is more accureate.
346
346
  #Net::LDAP::Filter.construct(
347
- # "(&(objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_basedn})(member=CN=#{uid},CN=Users,#{@ad_basedn}))")
347
+ # "(&(objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_base_dn})(member=CN=#{uid},CN=Users,#{@ad_base_dn}))")
348
348
 
349
349
  Net::LDAP::Filter.construct(
350
- "(&(objectClass=group)(member=CN=#{uid},#{@ad_user_basedn}))")
350
+ "(&(objectClass=group)(member=CN=#{uid},#{@ad_user_base_dn}))")
351
351
  else
352
- # TODO: Searching with filter `objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_basedn}` is more accureate.
352
+ # TODO: Searching with filter `objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_base_dn}` is more accureate.
353
353
  #Net::LDAP::Filter.construct(
354
- # "(&(objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_basedn})(|(member=CN=#{uid},CN=Users,#{@ad_basedn})(gidNumber=#{primary_gid_number})))")
354
+ # "(&(objectCategory=CN=Group,CN=Schema,CN=Configuration,#{@ad_base_dn})(|(member=CN=#{uid},CN=Users,#{@ad_base_dn})(gidNumber=#{primary_gid_number})))")
355
355
 
356
356
  Net::LDAP::Filter.construct(
357
- "(&(objectClass=group)(|(member=CN=#{uid},#{@ad_user_basedn})(gidNumber=#{primary_gid_number})))")
357
+ "(&(objectClass=group)(|(member=CN=#{uid},#{@ad_user_base_dn})(gidNumber=#{primary_gid_number})))")
358
358
  end
359
359
 
360
360
  # Get groups from AD
361
361
  # entry = {
362
362
  # :gidnumber => xxx,
363
363
  # }
364
- @ad_client.search(:base => @ad_group_basedn, :filter => ad_filter, :attributes => [:cn, :gidnumber]) do |entry|
364
+ @ad_client.search(:base => @ad_group_base_dn, :filter => ad_filter, :attributes => [:cn, :gidnumber]) do |entry|
365
365
  ad_group_map[entry[:cn].first] = {:gidnumber => entry[:gidnumber]}
366
366
  #ad_group_map[entry[:cn]] = nil
367
367
  end
@@ -377,7 +377,7 @@ class Adap
377
377
  ldap_filter = Net::LDAP::Filter.construct("(memberUid=#{uid})")
378
378
 
379
379
  # Get groups from LDAP
380
- @ldap_client.search(:base => @ldap_group_basedn, :filter => ldap_filter, :attributes => [:cn]) do |entry|
380
+ @ldap_client.search(:base => @ldap_group_base_dn, :filter => ldap_filter, :attributes => [:cn]) do |entry|
381
381
  # Capture common name of groups. gidnumber is not necessary for LDAP entry
382
382
  ldap_group_map[entry[:cn].first] = nil
383
383
  end
@@ -416,7 +416,7 @@ class Adap
416
416
  operation_pool = {}
417
417
 
418
418
  ad_group_map.each_key do |key|
419
- dn = "cn=#{key},#{@ldap_group_basedn}"
419
+ dn = "cn=#{key},#{@ldap_group_base_dn}"
420
420
  # Convert AD entries to LDAP entries to create operation to update LDAP data.
421
421
  operation_pool[dn] = {
422
422
  :cn => key,
@@ -426,7 +426,7 @@ class Adap
426
426
  end
427
427
 
428
428
  ldap_group_map.each_key do |key|
429
- operation_pool["cn=#{key},#{@ldap_group_basedn}"] = {
429
+ operation_pool["cn=#{key},#{@ldap_group_base_dn}"] = {
430
430
  # :cn and :gidnumber are not necessary
431
431
  :operations => [[:delete, :memberuid, uid]]
432
432
  } if !ad_group_map.has_key?(key)
@@ -555,7 +555,7 @@ class Adap
555
555
  return nil if uid ==nil
556
556
  primary_gid = nil
557
557
 
558
- @ad_client.search(:base => "CN=#{uid},CN=Users,#{@ad_basedn}") do |entry|
558
+ @ad_client.search(:base => "CN=#{uid},CN=Users,#{@ad_base_dn}") do |entry|
559
559
  primary_gid = entry[:gidnumber].first
560
560
  end
561
561
 
data/lib/adap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ModAdap
2
- VERSION = "0.1.10"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsutomu Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-08 00:00:00.000000000 Z
11
+ date: 2025-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,6 +65,7 @@ files:
65
65
  - Gemfile
66
66
  - Gemfile.lock
67
67
  - README.md
68
+ - README_FOR_DEVELOPER.md
68
69
  - Rakefile
69
70
  - adap.gemspec
70
71
  - bin/console