Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .autotest
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# -*- ruby -*-

require 'autotest/restart'

# Autotest.add_hook :initialize do |at|
# at.extra_files << "../some/external/dependency.rb"
#
# at.libs << ":../some/external"
#
# at.add_exception 'vendor'
#
# at.add_mapping(/dependency.rb/) do |f, _|
# at.files_matching(/test_.*rb$/)
# end
#
# %w(TestA TestB).each do |klass|
# at.extra_class_map[klass] = "test/test_misc.rb"
# end
# end

# Autotest.add_hook :run_command do |at|
# system "rake build"
# end
# -*- ruby -*-
require 'autotest/restart'
# Autotest.add_hook :initialize do |at|
# at.extra_files << "../some/external/dependency.rb"
#
# at.libs << ":../some/external"
#
# at.add_exception 'vendor'
#
# at.add_mapping(/dependency.rb/) do |f, _|
# at.files_matching(/test_.*rb$/)
# end
#
# %w(TestA TestB).each do |klass|
# at.extra_class_map[klass] = "test/test_misc.rb"
# end
# end
# Autotest.add_hook :run_command do |at|
# system "rake build"
# end
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo: required
language: ruby
rvm:
- "2.0.0"
- ruby-head
env:
- "PGVERSION=10.0-1-linux-x64 PATH=\"/opt/PostgreSQL/10/bin:$PATH\""
- "PGVERSION=9.3.19-1-linux-x64 PATH=\"/opt/PostgreSQL/9.3/bin:$PATH\""
before_install:
- gem install bundler
- bundle install
# Download and install postgresql version to test against in /opt
- |
wget http://get.enterprisedb.com/postgresql/postgresql-$PGVERSION.run && \
chmod +x postgresql-$PGVERSION.run && \
sudo ./postgresql-$PGVERSION.run --extract-only 1 --mode unattended
script: rake test
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

# Specify your gem's dependencies in pg_ldap_sync.gemspec
gemspec
44 changes: 36 additions & 8 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
=== 0.1.1 / 2012-11-15

* Add ability to lowercase the LDAP name for use as PG role name

=== 0.1.0 / 2011-07-13

* Birthday!

=== 0.2.1 / 2018-08-03 (Lloyd)
* Add pg_ldap_sync --version
* Fix compatibility with PostgreSQL-10
* Don't abort on SQL errors, but print ERROR notice
* Run sync within a SQL transaction, so that no partial sync happens
* Todo: Add Larskanis updates to the test suite and add the automated tests.

=== 0.2.0 / 2018-03-13 (Larskanis)

* Update gem dependencies
* Fix compatibility to pg-1.0 gem
* Add pg_ldap_sync --version
* Fix compatibility with PostgreSQL-10
* Don't abort on SQL errors, but print ERROR notice
* Run sync within a SQL transaction, so that no partial sync happens
* Lots of improvements to the test suite
* Run automated tests on Travis-CI and Appveyor
* Remove support for postgres-pr, since it's no longer maintained

=== 0.1.2 / 2016-10-18 (Lloyd)

* Add ability to have ldap groups and users with the same name merge into a single PG role
* Fixed to make dn's case insensitive as LDAP is case aware but not case sensitive
* Script will warn instead of die if role still owns objects in the database and can't be deleted from the database
* Script will warn about duplicate role. You should only run into this the first time you run this script against an existing server and you are using the "ldap_users" and "ldap_groups".
* Added testing for usage of "ldap_users" and "ldap_groups" group name
* Added "grant_this_group" to the pg_users and pg_groups YAML config file to support moving a user to become group to become user and to auto create these groups if they do not exist

=== 0.1.1 / 2012-11-15

* Add ability to lowercase the LDAP name for use as PG role name

=== 0.1.0 / 2011-07-13

* Birthday!

38 changes: 23 additions & 15 deletions Manifest.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
.autotest
History.txt
Manifest.txt
README.rdoc
Rakefile
bin/pg_ldap_sync
config/sample-config.yaml
config/sample-config2.yaml
config/schema.yaml
lib/pg_ldap_sync.rb
lib/pg_ldap_sync/application.rb
test/fixtures/config-ldapdb.yaml
test/fixtures/ldapdb.yaml
test/ldap_server.rb
test/test_pg_ldap_sync.rb
.autotest
History.txt
Manifest.txt
README.rdoc
Rakefile
exe/pg_ldap_sync
config/sample-config.yaml
config/sample-config2.yaml
config/sample-config3.yaml
config/sample-config4.yaml
config/schema.yaml
lib/pg_ldap_sync.rb
lib/pg_ldap_sync/application.rb
lib/pg_ldap_sync/logger.rb
lib/pg_ldap_sync/version.rb
test/fixtures/config-ldapdb.yaml
test/fixtures/config-ldapdb2.yaml
test/fixtures/config-ldapdb3.yaml
test/fixtures/config-ldapdb4.yaml
test/fixtures/ldapdb.yaml
test/fixtures/ldapdb3.yaml
test/ldap_server.rb
test/test_pg_ldap_sync.rb
204 changes: 93 additions & 111 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,111 +1,93 @@
= Use LDAP permissions in PostgreSQL

* http://github.com/larskanis/pg-ldap-sync

== DESCRIPTION:

LDAP is often used for a centralized user and role management
in an enterprise environment. PostgreSQL offers different
authentication methods, like LDAP, SSPI, GSSAPI or SSL.
However, for any method the user must already exist in the database,
before the authentication can be used. There is currently
no direct authorization of database users on LDAP. So roles
and memberships has to be administered twice.

This program helps to solve the issue by synchronizing users,
groups and their memberships from LDAP to PostgreSQL.
Access to LDAP is used read-only. <tt>pg_ldap_sync</tt> issues proper
CREATE ROLE, DROP ROLE, GRANT and REVOKE commands to synchronize
users and groups.

It is meant to be started as a cron job.

== FEATURES:

* Configurable per YAML config file
* Can use Active Directory as LDAP-Server
* Nested groups/roles supported
* Set scope of considered users/groups on LDAP and PG side
* Runs with pg.gem (C-library) or postgres-pr.gem (pure Ruby)
* Test mode which doesn't do any changes to the DBMS
* Both LDAP and PG connections can be secured by SSL/TLS

== REQUIREMENTS:

* Ruby-1.8.7, Ruby-1.9.2, JRuby-1.2, Rubinius-1.2 or better
* Rubygems-1.3.5+
* LDAP-v3 server
* PostgreSQL-server v8.1+

== INSTALL:

Install Ruby and rubygems:
* on Windows: http://rubyinstaller.org
* on Debian/Ubuntu: <tt>apt-get install ruby rubygems</tt>

Install pg-ldap-sync and a database connector for PostgreSQL:
gem install pg-ldap-sync pg
You may also use the pure ruby postgres-connector which is less mature,
but doesn't need compilation:
gem install pg-ldap-sync postgres-pr

=== Install from Git:
git clone https://github.com/larskanis/pg-ldap-sync.git
cd pg-ldap-sync
gem install hoe
rake install_gem

== USAGE:

Create a config file based on
{config/sample-config.yaml}[https://github.com/larskanis/pg-ldap-sync/blob/master/config/sample-config.yaml]
or even better
{config/sample-config2.yaml}[https://github.com/larskanis/pg-ldap-sync/blob/master/config/sample-config2.yaml]

Run in test-mode:

pg_ldap_sync -c my_config.yaml -vv -t

Run in modify-mode:

pg_ldap_sync -c my_config.yaml -vv


== TEST:
There is a small test suite in the <tt>test</tt> directory that runs
against an internal ruby-ldapserver and PostgreSQL server. Ensure gem
<tt>ruby-ldapserver</tt> is installed and <tt>pg_ctl</tt>, <tt>initdb</tt> and <tt>psql</tt>
commands are in the <tt>PATH</tt>. Then:

cd pg-ldap-sync
rake test

== ISSUES:
* There is currently no way to set certain user attributes in PG
based on individual attributes in LDAP (expiration date etc.)


== LICENSE:

(The MIT License)

Copyright (c) 2011 FIX

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
= Use LDAP permissions in PostgreSQL

* http://github.com/larskanis/pg-ldap-sync

== DESCRIPTION:

LDAP is often used for a centralized user and role management
in an enterprise environment. PostgreSQL offers different
authentication methods, like LDAP, SSPI, GSSAPI or SSL.
However, for any method the user must already exist in the database,
before the authentication can be used. There is currently
no direct authorization of database users on LDAP. So roles
and memberships has to be administered twice.

This program helps to solve the issue by synchronizing users,
groups and their memberships from LDAP to PostgreSQL.
Access to LDAP is used read-only. <tt>pg_ldap_sync</tt> issues proper
CREATE ROLE, DROP ROLE, GRANT and REVOKE commands to synchronize
users and groups.

It is meant to be started as a cron job.

== FEATURES:

* Configurable per YAML config file
* Can use Active Directory as LDAP-Server
* Nested groups/roles supported
* Set scope of considered users/groups on LDAP and PG side
* Runs with pg.gem (C-library) or postgres-pr.gem (pure Ruby)
* Test mode which doesn't do any changes to the DBMS
* Both LDAP and PG connections can be secured by SSL/TLS
* Supports LDAP users and groups with the same names
* Ability to have ldap groups and users with the same name merge into a single Postgres role

== REQUIREMENTS:

* Ruby-1.8.7, Ruby-1.9.2, JRuby-1.2, Rubinius-1.2 or better
* Rubygems-1.3.5+
* LDAP-v3 server
* PostgreSQL-server v9.0+

== INSTALL:

Install Ruby and rubygems:
* on Windows: http://rubyinstaller.org
* on Debian/Ubuntu: <tt>apt-get install ruby libpq-dev</tt>

Install pg-ldap-sync and a database connector for PostgreSQL:
gem install pg-ldap-sync pg
You may also use the pure ruby postgres-connector which is less mature,
but doesn't need compilation:
gem install pg-ldap-sync postgres-pr

=== Install from Git:
git clone https://github.com/larskanis/pg-ldap-sync.git
cd pg-ldap-sync
gem install bundler
bundle install
bundle exec rake install

== USAGE:

Create a config file based on
{config/sample-config.yaml}[https://github.com/larskanis/pg-ldap-sync/blob/master/config/sample-config.yaml]
or even better
{config/sample-config2.yaml}[https://github.com/larskanis/pg-ldap-sync/blob/master/config/sample-config2.yaml]

Run in test-mode:

pg_ldap_sync -c my_config.yaml -vv -t

Run in modify-mode:

pg_ldap_sync -c my_config.yaml -vv


== TEST:
There is a small test suite in the <tt>test</tt> directory that runs
against an internal ruby-ldapserver and PostgreSQL server. Ensure gem
<tt>ruby-ldapserver</tt> is installed and <tt>pg_ctl</tt>, <tt>initdb</tt> and <tt>psql</tt>
commands are in the <tt>PATH</tt>. Then:

cd pg-ldap-sync
rake test

== ISSUES:
* There is currently no way to set certain user attributes in PG
based on individual attributes in LDAP (expiration date etc.)


== LICENSE:

The gem is available as open source under the terms of the {MIT License}[https://opensource.org/licenses/MIT].
29 changes: 11 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'

Hoe.spec 'pg-ldap-sync' do
developer('Lars Kanis', '[email protected]')

extra_deps << ['net-ldap', '>= 0.2']
extra_deps << ['kwalify', '>= 0.7']
extra_dev_deps << ['ruby-ldapserver', '>= 0.3']

self.readme_file = 'README.rdoc'
spec_extras[:rdoc_options] = ['--main', readme_file, "--charset=UTF-8"]
self.extra_rdoc_files << self.readme_file
end

# vim: syntax=ruby
# -*- ruby -*-
require "bundler/gem_tasks"
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end

task :gem => :build
6 changes: 0 additions & 6 deletions bin/pg_ldap_sync

This file was deleted.

Loading