pg-ldap-sync 0.4.0 → 0.5.0

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
  SHA256:
3
- metadata.gz: 3630b9ed2307ae5d629896016d302f8ccfee7e324ca963b2ba6dfe1cee612351
4
- data.tar.gz: f2065307ea2d61d6e2498e604c3d2105248380a27039601808be6b24579ef586
3
+ metadata.gz: a08af19305647e9c74adbf8d4354f826d95eea24e3ac9d362e1f32df2e347f2e
4
+ data.tar.gz: b07f7ef2e6eee98529979b8b935dcf0d1a5b5e29535ba499824b36cfb71ebbca
5
5
  SHA512:
6
- metadata.gz: 449792e68c3cf512209e42231b134fec4a090bb873473e4db844eb50a3f9be87cd23c07676bd80ffbf604774f6a72d1d7b508cee13d8f703577c19a4312d9975
7
- data.tar.gz: 2bbe1be11834f35b361dc0a255cd8e02323aa2f000940efcec6e695bfa5e2653ff940c883cd6264462afda36d8125913ac012c7e89d760440345d67cd48bddd5
6
+ metadata.gz: ab386f3df54231fd962696446d38ce9cf2fa0bdef9bd383b9e9af72a96eb67527be1bb7ddf09133f80fd92a5e2868e5d07269a87bf0b45d648c732b5ae643017
7
+ data.tar.gz: 05631b8dea00b093943017f425cb82dd64edb2323afda113bafee01235368c1526f2386236de84979654c2c495c102ff1e7f441a1538199581730772d5845721
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.0 / 2023-08-24
2
+
3
+ * Add Kerberos and NTLM authentication support
4
+ * Fix retrieval of groups with over 1500 users in Active Directory server. #45
5
+
6
+
1
7
  ## 0.4.0 / 2022-12-02
2
8
 
3
9
  * Support groups with over 1500 users in Active Directory server. #32
data/Gemfile CHANGED
@@ -5,5 +5,4 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem "debug"
8
- gem "ruby-ldapserver", git: "https://github.com/larskanis/ruby-ldapserver/"
9
8
  end
data/README.md CHANGED
@@ -20,16 +20,18 @@ It is meant to be started as a cron job.
20
20
 
21
21
  ## FEATURES:
22
22
 
23
+ * User+group creation, deletion and changes in memberships are synchronized from LDAP to PostgreSQL
24
+ * Nested groups/roles supported
23
25
  * Configurable per YAML config file
24
26
  * Can use Active Directory as LDAP-Server
25
- * Nested groups/roles supported
26
27
  * Set scope of considered users/groups on LDAP and PG side
27
28
  * Test mode which doesn't do any changes to the DBMS
28
29
  * Both LDAP and PG connections can be secured by SSL/TLS
30
+ * NTLM and Kerberos authentication to LDAP server
29
31
 
30
32
  ## REQUIREMENTS:
31
33
 
32
- * Ruby-2.0+, JRuby-1.2+
34
+ * Ruby-2.0+
33
35
  * LDAP-v3 server
34
36
  * PostgreSQL-server v9.0+
35
37
 
@@ -70,6 +72,11 @@ Run in modify-mode:
70
72
  pg_ldap_sync -c my_config.yaml -vv
71
73
  ```
72
74
 
75
+ It is recommended to avoid granting permissions to synchronized users on the PostgreSQL server, but to grant permissions to groups instead.
76
+ This is because `DROP USER` statements invoked when a user leaves otherwise fail due to depending objects.
77
+ `DROP GROUP` equally fails if there are depending objects, but groups are typically more stable and removed rarely.
78
+
79
+
73
80
  ## TEST:
74
81
  There is a small test suite in the `test` directory that runs against an internal LDAP server and a PostgreSQL server. Ensure `pg_ctl`, `initdb` and `psql` commands are in the `PATH` like so:
75
82
  ```sh
@@ -5,13 +5,26 @@
5
5
  # Connection parameters to LDAP server
6
6
  # see also: http://net-ldap.rubyforge.org/Net/LDAP.html#method-c-new
7
7
  ldap_connection:
8
- host: localhost
8
+ host: ldapserver
9
9
  port: 389
10
10
  auth:
11
11
  method: :simple
12
12
  username: CN=username,OU=!Serviceaccounts,OU=company,DC=company,DC=de
13
13
  password: secret
14
14
 
15
+ # or GSSAPI / Kerberos authentication:
16
+ auth:
17
+ method: :gssapi
18
+ hostname: ldapserver.company.de
19
+ servicename: ldap # optional, defaults to "ldap"
20
+
21
+ # or GSS-SPNEGO / NTLM authentication
22
+ auth:
23
+ method: :gss_spnego
24
+ username: 'myuser'
25
+ password: 'secret'
26
+ domain: 'company.de' # optional
27
+
15
28
  # Search parameters for LDAP users which should be synchronized
16
29
  ldap_users:
17
30
  base: OU=company,OU=company,DC=company,DC=de
@@ -51,4 +64,5 @@ pg_groups:
51
64
  filter: NOT rolcanlogin AND NOT rolsuper
52
65
  # Options for CREATE RULE statements
53
66
  create_options: NOLOGIN
67
+ # Options for GRANT <role> TO <group> statements
54
68
  grant_options:
@@ -1,9 +1,11 @@
1
1
  # With this sample config the distinction between LDAP-synchronized
2
- # groups/users from is done by the membership to ldap_user and
3
- # ldap_group. These two roles have to be defined manally before
4
- # pg_ldap_sync can run:
5
- # CREATE GROUP ldap_group;
6
- # CREATE USER ldap_user;
2
+ # groups/users from manually created PostgreSQL users is done by the
3
+ # membership in ldap_user and ldap_group.
4
+ # These two roles have to be defined manally before pg_ldap_sync can
5
+ # run and all synchronized users/groups will become member of them
6
+ # later on:
7
+ # CREATE GROUP ldap_groups;
8
+ # CREATE USER ldap_users;
7
9
  #
8
10
 
9
11
  # Connection parameters to LDAP server
@@ -63,4 +65,5 @@ pg_groups:
63
65
  filter: oid IN (SELECT pam.member FROM pg_auth_members pam JOIN pg_roles pr ON pr.oid=pam.roleid WHERE pr.rolname='ldap_groups')
64
66
  # Options for CREATE RULE statements
65
67
  create_options: NOLOGIN IN ROLE ldap_groups
68
+ # Options for GRANT <role> TO <group> statements
66
69
  grant_options:
@@ -103,7 +103,7 @@ class Application
103
103
  array += entry[ranged_attr]
104
104
  log.debug "retrieved attribute range #{ranged_attr.inspect} of dn #{entry_dn}"
105
105
 
106
- if ranged_attr =~ /;range=\d\-\*\z/
106
+ if ranged_attr =~ /;range=\d+\-\*\z/
107
107
  break
108
108
  end
109
109
 
@@ -361,8 +361,26 @@ class Application
361
361
  def start!
362
362
  read_config_file(@config_fname)
363
363
 
364
+ ldap_conf = @config[:ldap_connection]
365
+ auth_meth = ldap_conf.dig(:auth, :method).to_s
366
+ if auth_meth == "gssapi"
367
+ begin
368
+ require 'net/ldap/auth_adapter/gssapi'
369
+ rescue LoadError => err
370
+ raise "#{err}\nTo use GSSAPI authentication please run:\n gem install net-ldap-auth_adapter-gssapi"
371
+ end
372
+ elsif auth_meth == "gss_spnego"
373
+ begin
374
+ require 'net-ldap-gss-spnego'
375
+ # This doesn't work since this file is defined in net-ldap as a placeholder:
376
+ # require 'net/ldap/auth_adapter/gss_spnego'
377
+ rescue LoadError => err
378
+ raise "#{err}\nTo use GSSAPI authentication please run:\n gem install net-ldap-gss-spnego"
379
+ end
380
+ end
381
+
364
382
  # gather LDAP users and groups
365
- @ldap = Net::LDAP.new @config[:ldap_connection]
383
+ @ldap = Net::LDAP.new ldap_conf
366
384
  ldap_users = uniq_names search_ldap_users
367
385
  ldap_groups = uniq_names search_ldap_groups
368
386
 
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  class Hash
4
+ # transform_keys was added in ruby-2.5
4
5
  def transform_keys
5
6
  map do |k, v|
6
7
  [yield(k), v]
@@ -1,3 +1,3 @@
1
1
  module PgLdapSync
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/pg-ldap-sync.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "net-ldap", "~> 0.16"
25
25
  spec.add_runtime_dependency "kwalify", "~> 0.7"
26
26
  spec.add_runtime_dependency "pg", ">= 0.14", "< 2.0"
27
- spec.add_development_dependency "ruby-ldapserver", "~> 0.3"
27
+ spec.add_development_dependency "ruby-ldapserver", "~> 0.7"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
29
  spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
30
30
  spec.add_development_dependency "rake", "~> 13.0"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg-ldap-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Kanis
@@ -10,9 +10,9 @@ bindir: exe
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
14
- L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yMjAyMTQxMzMwNTZaFw0yMzAy
15
- MTQxMzMwNTZaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
13
+ MIIEBDCCAmygAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
14
+ L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yMzAyMTUxNzQxMTVaFw0yNDAy
15
+ MTUxNzQxMTVaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
16
16
  PWRlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwum6Y1KznfpzXOT/
17
17
  mZgJTBbxZuuZF49Fq3K0WA67YBzNlDv95qzSp7V/7Ek3NCcnT7G+2kSuhNo1FhdN
18
18
  eSDO/moYebZNAcu3iqLsuzuULXPLuoU0GsMnVMqV9DZPh7cQHE5EBZ7hlzDBK7k/
@@ -21,21 +21,19 @@ cert_chain:
21
21
  JMNDFsmHK/6Ji4Kk48Z3TyscHQnipAID5GhS1oD21/WePdj7GhmbF5gBzkV5uepd
22
22
  eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
23
23
  chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
24
- 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjgYEwfzAJ
25
- BgNVHRMEAjAAMAsGA1UdD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xQfN/EE
29
+ VMlnDJ1P7mUHAvpK8X9j9h7Xlc1niViT18MYwux8mboVTryrLr+clATUkkM3yBF0
30
+ RV+c34ReW5eXO9Tr6aKTxh/pFC9ggDT6jOxuJgSvG8HWJzVf4NDvMavIas4KYjiI
31
+ BU6CpWaG5NxicqL3BERi52U43HV08br+LNVpb7Rekgve/PJuSFnAR015bhSRXe5U
32
+ vBioD1qW2ZW9tXg8Ww2IfDaO5a1So5Xby51rhNlyo6ATj2NkuLWZUKPKHhAz0TKm
33
+ Dzx/gFSOrRoCt2mXNgrmcAfr386AfaMvCh7cXqdxZwmVo7ILZCYXck0pajvubsDd
34
+ NUIIFkVXvd1odFyK9LF1RFAtxn/iAmpx
37
35
  -----END CERTIFICATE-----
38
- date: 2022-12-02 00:00:00.000000000 Z
36
+ date: 2023-08-24 00:00:00.000000000 Z
39
37
  dependencies:
40
38
  - !ruby/object:Gem::Dependency
41
39
  name: net-ldap
@@ -91,14 +89,14 @@ dependencies:
91
89
  requirements:
92
90
  - - "~>"
93
91
  - !ruby/object:Gem::Version
94
- version: '0.3'
92
+ version: '0.7'
95
93
  type: :development
96
94
  prerelease: false
97
95
  version_requirements: !ruby/object:Gem::Requirement
98
96
  requirements:
99
97
  - - "~>"
100
98
  - !ruby/object:Gem::Version
101
- version: '0.3'
99
+ version: '0.7'
102
100
  - !ruby/object:Gem::Dependency
103
101
  name: minitest
104
102
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
210
  - !ruby/object:Gem::Version
213
211
  version: '0'
214
212
  requirements: []
215
- rubygems_version: 3.3.7
213
+ rubygems_version: 3.4.6
216
214
  signing_key:
217
215
  specification_version: 4
218
216
  summary: Use LDAP permissions in PostgreSQL
metadata.gz.sig CHANGED
Binary file