roleman
pg_roleman · Parameterized role and privilege management functions for PostgreSQL.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100170 | roleman | pg_roleman | 0.3.0 | SEC | PostgreSQL | SQL |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
roleman 0.3.0 is a pure-SQL API for parameterized role creation, alteration, password changes, grants, role settings, and removal. It quotes identifiers and whitelists role attributes and privilege keywords, helping applications avoid constructing raw utility SQL themselves.
Create and Configure a Role
The extension installs into the fixed roleman schema and requires superuser installation. Its functions are security-invoker functions: the caller still needs the PostgreSQL privileges required by the resulting CREATE ROLE, ALTER ROLE, GRANT, REVOKE, or DROP ROLE command.
Main Function Groups
roleman.create_role(text, text[])androleman.alter_base(text, text[])apply whitelisted role attributes.roleman.role_set_password(text, text, timestamp)sets a password and optional expiry.roleman.grant_database,roleman.grant_schema,roleman.grant_schema_all,roleman.grant_table,roleman.grant_seq, androleman.grant_functionapply whitelisted privileges.roleman.role_grant_role(text, text)grants role membership.roleman.set_guc,roleman.set_guc_from_current,roleman.set_connection_limit, androleman.set_search_pathalter role defaults.roleman.role_blank_perms(text)broadly revokes privileges and memberships visible from the current database;roleman.drop_role(text)removes the role.
Safety and Known Defects
Password values travel as SQL function arguments and can be exposed through statement logging, activity views, monitoring, or error context. Use encrypted connections and a credential workflow that prevents SQL text capture.
roleman.role_blank_perms(text) is destructive and incomplete as a global reset: it loops over schemas in the current database and revokes explicit database/object privileges and memberships, but does not transfer ownership, remove default privileges, or inspect every other database. Inventory dependencies and test the exact revocation plan first.
The 0.3.0 implementation of roleman.reset_guc(text, text) mistakenly issues ALTER USER ... SET ... FROM CURRENT instead of resetting the setting. Do not call it; use a reviewed native ALTER ROLE ... RESET ... command. The project is archived and was tested historically around PostgreSQL 9.4 through 9.6, with PostgreSQL 10 only expected, not established. Regression-test its catalog queries and generated utility commands on the exact target release.