pg_idm
pg_idm · Exposes PostgreSQL role and membership management through updatable views and DML-trigger functions.
Overview
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
pg_idm exposes PostgreSQL roles and role memberships as writable relational views. INSERT, UPDATE, and DELETE operations are translated by INSTEAD OF triggers into role DDL, which can simplify tightly controlled identity-management integrations. The rows represent cluster-wide security principals, not data local to one database.
Install it in a dedicated caller-chosen schema because the extension is non-relocatable after creation and uses generic object names.
Manage Roles
idm.roles projects the attributes in pg_roles, including rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolconnlimit, rolpassword, rolvaliduntil, and rolbypassrls. Omitted insert attributes use the extension’s role defaults; updates generate only changed role options.
Manage Memberships
idm.auth_members mirrors pg_auth_members; inserts issue GRANT and deletes issue REVOKE. The view does not provide an update workflow for memberships.
Security and Operational Notes
- Trigger functions are explicitly
SECURITY INVOKER. A caller needs both DML privileges on the views and the PostgreSQL authority required for the generated role command; the extension does not elevate the caller. - Role changes affect every database in the cluster. Restrict write grants to a dedicated administrative role, audit them like direct role DDL, and test ownership and dependency failures before automated deletion.
- Password values supplied through DML can appear in client history, SQL logs, audit records, or monitoring. Prefer approved secret-handling and parameterized interfaces; do not use the view as a password-distribution channel without reviewing those paths.
- The control file says installation itself does not require a superuser, but actual role attributes such as
SUPERUSER,REPLICATION, andBYPASSRLSremain subject to core PostgreSQL privilege rules. - Upstream version
1.0claims PostgreSQL 9.6 and later but publishes no maintained compatibility matrix. Verify generated DDL and catalog columns against the exact server major in use.