Skip to content
🐘 👥 Manage PostgreSQL roles and privileges from YAML or LDAP
Python Shell Other
Branch: master
Clone or download
bersace Merge pull request #301 from TonCherAmi/patch-1
Fix typo in psycopg2 package name
Latest commit ad0d6c3 Jan 9, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.github/ISSUE_TEMPLATE Restore regulard issue template directory Jul 2, 2019
docker Lint Docker README Nov 6, 2019
docs
fixtures Respect case of role name Nov 6, 2019
ldap2pg Manage renaming of roles Nov 6, 2019
packaging
tests Manage renaming of roles Nov 6, 2019
.all-contributorsrc Create AUTHORS.md Aug 26, 2019
.gitignore Ignore .pytest_cache/ directory Feb 28, 2018
AUTHORS.md
CHANGELOG.md Link changelog to standard location Mar 14, 2019
CONTRIBUTING.md Create AUTHORS.md Aug 26, 2019
LICENSE Fix license autodetection by GitHub Dec 21, 2017
Makefile
README.rst Fix typo in psycopg2 package name Jan 9, 2020
docker-compose.ha.yml Move dev compose to bersace/openldap Jan 8, 2018
docker-compose.yml Move to Postgres 12 Nov 5, 2019
ldap2pg.yml
ldaprc
mkdocs.yml
requirements-ci.txt Merge pull request #267 from bersace/warn Feb 20, 2019
setup.cfg Restore universal wheel Dec 20, 2017
setup.py Version 5.1 Nov 7, 2019

README.rst

ldap2pg: PostgreSQL role and privileges management

Swiss-army knife to synchronize Postgres roles and privileges from YAML or LDAP.

Features

  • Creates, alters and drops PostgreSQL roles from LDAP queries.
  • Creates static roles from YAML to complete LDAP entries.
  • Manages role members (alias groups).
  • Grants or revokes privileges statically or from LDAP entries.
  • Dry run.
  • Logs LDAP queries as ldapsearch commands.
  • Logs every SQL query.
  • Reads settings from an expressive YAML config file.

Here is a sample configuration and execution:

$ cat ldap2pg.yml
- role:
    name: ldap_roles
    options: NOLOGIN
- ldap:
    base: ou=people,dc=ldap,dc=ldap2pg,dc=docker
    filter: "(objectClass=organizationalPerson)"
  role:
    name: '{cn}'
    options: LOGIN
    parent: ldap_roles
$ ldap2pg --real
Starting ldap2pg 5.0.
Using .../ldap2pg.yml.
Running in real mode.
Inspecting roles in Postgres cluster...
Querying LDAP ou=people,dc=ldap,dc=lda... (objectClass...
Create domitille.
Update options of albert.
Add missing ldap_roles members.
Delete spurious ldap_roles members.
Reassign oscar objects and purge ACL on postgres.
Reassign oscar objects and purge ACL on template1.
Drop oscar.
Synchronization complete.
$

See versionned ldap2pg.yml and documentation for further options.

Installation

Install it from PyPI tarball:

pip install ldap2pg psycopg2-binary

More details can be found in documentation.

ldap2pg is licensed under PostgreSQL license. ldap2pg is available with the help of wonderful people, jump to contributors list to see them.

Support

If you need support and you didn't found it in documentation, just drop a question in a GitHub issue! Don't miss the cookbook. You're welcome!

You can’t perform that action at this time.