pg-ldap-sync 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -1,3 +1,7 @@
1
+ === 0.1.1 / 2012-11-15
2
+
3
+ * Add ability to lowercase the LDAP name for use as PG role name
4
+
1
5
  === 0.1.0 / 2011-07-13
2
6
 
3
7
  * Birthday!
@@ -4,16 +4,17 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- LDAP is often used to do a centralized user and role management
7
+ LDAP is often used for a centralized user and role management
8
8
  in an enterprise environment. PostgreSQL offers different
9
9
  authentication methods, like LDAP, SSPI, GSSAPI or SSL.
10
10
  However, for any method the user must already exist in the database,
11
11
  before the authentication can be used. There is currently
12
- no authorization of database users directly based on LDAP.
12
+ no direct authorization of database users on LDAP. So roles
13
+ and memberships has to be administered twice.
13
14
 
14
15
  This program helps to solve the issue by synchronizing users,
15
16
  groups and their memberships from LDAP to PostgreSQL.
16
- Access to LDAP is read-only. <tt>pg_ldap_sync</tt> issues proper
17
+ Access to LDAP is used read-only. <tt>pg_ldap_sync</tt> issues proper
17
18
  CREATE ROLE, DROP ROLE, GRANT and REVOKE commands to synchronize
18
19
  users and groups.
19
20
 
@@ -24,13 +25,17 @@ It is meant to be started as a cron job.
24
25
  * Configurable per YAML config file
25
26
  * Can use Active Directory as LDAP-Server
26
27
  * Nested groups/roles supported
28
+ * Set scope of considered users/groups on LDAP and PG side
27
29
  * Runs with pg.gem (C-library) or postgres-pr.gem (pure Ruby)
28
30
  * Test mode which doesn't do any changes to the DBMS
31
+ * Both LDAP and PG connections can be secured by SSL/TLS
29
32
 
30
33
  == REQUIREMENTS:
31
34
 
32
- * Installed Ruby and rubygems
33
- * LDAP- and PostgreSQL-Server
35
+ * Ruby-1.8.7, Ruby-1.9.2, JRuby-1.2, Rubinius-1.2 or better
36
+ * Rubygems-1.3.5+
37
+ * LDAP-v3 server
38
+ * PostgreSQL-server v8.1+
34
39
 
35
40
  == INSTALL:
36
41
 
@@ -31,7 +31,7 @@ ldap_groups:
31
31
  member_attribute: member
32
32
 
33
33
  # Connection parameters to PostgreSQL server
34
- # see also: http://rubydoc.info/gems/pg/0.11.0/PGconn#initialize-instance_method
34
+ # see also: http://rubydoc.info/gems/pg/PG/Connection#initialize-instance_method
35
35
  pg_connection:
36
36
  host:
37
37
  dbname: postgres
@@ -1,6 +1,7 @@
1
1
  # With this sample config the distinction between LDAP-synchronized
2
2
  # groups/users from is done by the membership to ldap_user and
3
- # ldap_group. These two roles has to be defined manally.
3
+ # ldap_group. These two roles has to be defined manally before
4
+ # pg_ldap_sync can run.
4
5
 
5
6
  # Connection parameters to LDAP server
6
7
  # see also: http://net-ldap.rubyforge.org/Net/LDAP.html#method-c-new
@@ -20,6 +21,8 @@ ldap_users:
20
21
  filter: (&(objectClass=person)(objectClass=organizationalPerson)(givenName=*)(sn=*)(sAMAccountName=*))
21
22
  # this attribute is used as PG role name
22
23
  name_attribute: sAMAccountName
24
+ # lowercase name for use as PG role name
25
+ lowercase_name: true
23
26
 
24
27
  # Search parameters for LDAP groups which should be synchronized
25
28
  ldap_groups:
@@ -27,11 +30,13 @@ ldap_groups:
27
30
  filter: (cn=company.*)
28
31
  # this attribute is used as PG role name
29
32
  name_attribute: cn
33
+ # lowercase name for use as PG role name
34
+ lowercase_name: false
30
35
  # this attribute must reference to all member DN's of the given group
31
36
  member_attribute: member
32
37
 
33
38
  # Connection parameters to PostgreSQL server
34
- # see also: http://rubydoc.info/gems/pg/0.11.0/PGconn#initialize-instance_method
39
+ # see also: http://rubydoc.info/gems/pg/PG/Connection#initialize-instance_method
35
40
  pg_connection:
36
41
  host:
37
42
  dbname: postgres
@@ -17,6 +17,9 @@ mapping:
17
17
  "name_attribute":
18
18
  type: str
19
19
  required: yes
20
+ "lowercase_name":
21
+ type: bool
22
+ required: no
20
23
 
21
24
  "ldap_groups":
22
25
  type: map
@@ -31,6 +34,9 @@ mapping:
31
34
  "name_attribute":
32
35
  type: str
33
36
  required: yes
37
+ "lowercase_name":
38
+ type: bool
39
+ required: no
34
40
  "member_attribute":
35
41
  type: str
36
42
  required: yes
@@ -1,3 +1,3 @@
1
1
  module PgLdapSync
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -85,6 +85,7 @@ class Application
85
85
  log.warn "user attribute #{ldap_user_conf[:name_attribute].inspect} not defined for #{entry.dn}"
86
86
  next
87
87
  end
88
+ name.downcase! if ldap_user_conf[:lowercase_name]
88
89
 
89
90
  log.info "found user-dn: #{entry.dn}"
90
91
  user = LdapRole.new name, entry.dn
@@ -111,6 +112,7 @@ class Application
111
112
  log.warn "user attribute #{ldap_group_conf[:name_attribute].inspect} not defined for #{entry.dn}"
112
113
  next
113
114
  end
115
+ name.downcase! if ldap_group_conf[:lowercase_name]
114
116
 
115
117
  log.info "found group-dn: #{entry.dn}"
116
118
  group = LdapRole.new name, entry.dn, entry[ldap_group_conf[:member_attribute]]
@@ -16,9 +16,9 @@ ldap_groups:
16
16
 
17
17
  pg_connection:
18
18
  dbname: postgres
19
+ host: localhost
20
+ port: 54321
19
21
  # needed for postgres-pr:
20
- # host: localhost
21
- # port: 54321
22
22
  # user: insert_your_username_here
23
23
  # password:
24
24
 
@@ -41,9 +41,9 @@ class TestPgLdapSync < Test::Unit::TestCase
41
41
  @port = 54321
42
42
  ENV['PGPORT'] = @port.to_s
43
43
  ENV['PGHOST'] = 'localhost'
44
- unless File.exist?('temp/pg_data')
44
+ unless File.exist?('temp/pg_data/PG_VERSION')
45
45
  FileUtils.mkdir_p 'temp/pg_data'
46
- log_and_run 'initdb', '-D', 'temp/pg_data'
46
+ log_and_run 'initdb', '-D', 'temp/pg_data', '--no-locale'
47
47
  end
48
48
  log_and_run 'pg_ctl', '-w', '-o', "-k.", '-D', 'temp/pg_data', 'start'
49
49
  log_and_run 'psql', '-e', '-c', "DROP ROLE IF EXISTS fred, wilma, \"Flintstones\", \"Wilmas\", \"All Users\"", 'postgres'
@@ -66,13 +66,22 @@ class TestPgLdapSync < Test::Unit::TestCase
66
66
  def psqlre(*args)
67
67
  /^\s*#{args[0]}[ |]*#{args[1]}[ |\{"]*#{args[2..-1].join('[", ]+')}["\}\s]*$/
68
68
  end
69
+
70
+ def exec_psql_du
71
+ text = if RUBY_PLATFORM=~/mingw|mswin/
72
+ `psql -c \\du postgres`
73
+ else
74
+ `psql -c \\\\du postgres`
75
+ end
76
+ puts text
77
+ return text
78
+ end
69
79
 
70
80
  def test_sanity
71
81
  PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
72
82
 
73
83
  ENV['LC_MESSAGES'] = 'C'
74
- psql_du = `psql -c \\\\du postgres`
75
- puts psql_du
84
+ psql_du = exec_psql_du
76
85
 
77
86
  assert_match(psqlre('All Users','Cannot login'), psql_du)
78
87
  assert_match(psqlre('Flintstones','Cannot login'), psql_du)
@@ -84,8 +93,7 @@ class TestPgLdapSync < Test::Unit::TestCase
84
93
  @directory['cn=Flintstones,dc=example,dc=com']['member'].pop
85
94
 
86
95
  PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
87
- psql_du = `psql -c \\\\du postgres`
88
- puts psql_du
96
+ psql_du = exec_psql_du
89
97
 
90
98
  assert_match(psqlre('All Users','Cannot login'), psql_du)
91
99
  assert_match(psqlre('Flintstones','Cannot login'), psql_du)
@@ -99,8 +107,7 @@ class TestPgLdapSync < Test::Unit::TestCase
99
107
  @directory['cn=Flintstones,dc=example,dc=com']['member'] << 'cn=Wilma Flintstone,dc=example,dc=com'
100
108
 
101
109
  PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
102
- psql_du = `psql -c \\\\du postgres`
103
- puts psql_du
110
+ psql_du = exec_psql_du
104
111
 
105
112
  assert_match(psqlre('All Users','Cannot login'), psql_du)
106
113
  assert_match(psqlre('Flintstones','Cannot login'), psql_du)
metadata CHANGED
@@ -1,110 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pg-ldap-sync
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Lars Kanis
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-13 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: net-ldap
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &9786620 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 0
32
- - 2
33
- version: "0.2"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.2'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: kwalify
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *9786620
25
+ - !ruby/object:Gem::Dependency
26
+ name: kwalify
27
+ requirement: &9783100 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 5
45
- segments:
46
- - 0
47
- - 7
48
- version: "0.7"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
49
33
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: ruby-ldapserver
53
34
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *9783100
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &9781660 !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 13
60
- segments:
61
- - 0
62
- - 3
63
- version: "0.3"
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.10'
64
44
  type: :development
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: hoe
68
45
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *9781660
47
+ - !ruby/object:Gem::Dependency
48
+ name: ruby-ldapserver
49
+ requirement: &9805140 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 47
75
- segments:
76
- - 2
77
- - 8
78
- - 0
79
- version: 2.8.0
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
80
55
  type: :development
81
- version_requirements: *id004
82
- description: |-
83
- LDAP is often used to do a centralized user and role management
56
+ prerelease: false
57
+ version_requirements: *9805140
58
+ - !ruby/object:Gem::Dependency
59
+ name: hoe
60
+ requirement: &9803940 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '3.0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *9803940
69
+ description: ! 'LDAP is often used for a centralized user and role management
70
+
84
71
  in an enterprise environment. PostgreSQL offers different
72
+
85
73
  authentication methods, like LDAP, SSPI, GSSAPI or SSL.
74
+
86
75
  However, for any method the user must already exist in the database,
76
+
87
77
  before the authentication can be used. There is currently
88
- no authorization of database users directly based on LDAP.
89
-
78
+
79
+ no direct authorization of database users on LDAP. So roles
80
+
81
+ and memberships has to be administered twice.
82
+
83
+
90
84
  This program helps to solve the issue by synchronizing users,
85
+
91
86
  groups and their memberships from LDAP to PostgreSQL.
92
- Access to LDAP is read-only. <tt>pg_ldap_sync</tt> issues proper
87
+
88
+ Access to LDAP is used read-only. <tt>pg_ldap_sync</tt> issues proper
89
+
93
90
  CREATE ROLE, DROP ROLE, GRANT and REVOKE commands to synchronize
91
+
94
92
  users and groups.
95
-
96
- It is meant to be started as a cron job.
97
- email:
93
+
94
+
95
+ It is meant to be started as a cron job.'
96
+ email:
98
97
  - kanis@comcard.de
99
- executables:
98
+ executables:
100
99
  - pg_ldap_sync
101
100
  extensions: []
102
-
103
- extra_rdoc_files:
101
+ extra_rdoc_files:
104
102
  - History.txt
105
103
  - Manifest.txt
106
104
  - README.rdoc
107
- files:
105
+ files:
108
106
  - .autotest
109
107
  - History.txt
110
108
  - Manifest.txt
@@ -120,41 +118,34 @@ files:
120
118
  - test/fixtures/ldapdb.yaml
121
119
  - test/ldap_server.rb
122
120
  - test/test_pg_ldap_sync.rb
123
- has_rdoc: true
121
+ - .gemtest
124
122
  homepage: http://github.com/larskanis/pg-ldap-sync
125
123
  licenses: []
126
-
127
124
  post_install_message:
128
- rdoc_options:
125
+ rdoc_options:
129
126
  - --main
130
127
  - README.rdoc
131
128
  - --charset=UTF-8
132
- require_paths:
129
+ require_paths:
133
130
  - lib
134
- required_ruby_version: !ruby/object:Gem::Requirement
131
+ required_ruby_version: !ruby/object:Gem::Requirement
135
132
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: 3
140
- segments:
141
- - 0
142
- version: "0"
143
- required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
138
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
152
143
  requirements: []
153
-
154
144
  rubyforge_project: pg-ldap-sync
155
- rubygems_version: 1.3.7
145
+ rubygems_version: 1.8.10
156
146
  signing_key:
157
147
  specification_version: 3
158
- summary: LDAP is often used to do a centralized user and role management in an enterprise environment
159
- test_files:
148
+ summary: LDAP is often used for a centralized user and role management in an enterprise
149
+ environment
150
+ test_files:
160
151
  - test/test_pg_ldap_sync.rb