pg_pass_policy
pg_pass_policy · Role password complexity, history, expiration, rotation and authentication lockout policies.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102302 | pg_pass_policy | pg_pass_policy | 1.0 | SEC | PostgreSQL | C |
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
pg_pass_policy manages PostgreSQL role password complexity, reuse history, expiry, rotation and authentication lockout. This source snapshot installs SQL version 1.0 and documents PostgreSQL 14–18. It controls cluster-wide authentication through hooks, but stores its policy in one designated database.
Enablement
Review an administrative exemption and rescue path before enabling it. Add the library to the existing preload list and restart PostgreSQL:
Connect as a superuser to the designated database only:
During startup, non-exempt logins can be refused with 57P03 until the worker loads lock state, including trust/peer connections. The separately configured rescue path admits only listed superusers using peer authentication. A missing worker slot or database can prevent initialization; do not enable this without a tested administrative recovery path.
Profiles and Administration
The default profile combines complexity, history, expiry and failed-login thresholds. SCRAM-SHA-256 is required by default. Password changes belong in pg_pass_policy.database; changes elsewhere are rejected when enforcement is enabled.
Installation creates the fixed pass_policy schema plus pass_policy_viewer and pass_policy_admin roles. Administration functions are SECURITY DEFINER and check session_user: connect directly as the authorized member rather than using SET ROLE. Restrict administrative membership because it can rotate non-privileged users’ credentials.
Rotation and Security Boundaries
pass_policy.rotate_password generates and applies a password; pass_policy.switch_rotation_pair supports paired-role rotation. Both return plaintext to the caller once. Protect transport with verified TLS and avoid retaining results in client grids, logs or terminal history; server-side handling does not protect client copies.
pass_policy.generate_password, pass_policy.check_password, pass_policy.failed_attempts and pass_policy.worker_status expose generation, preflight and operating state. Exempt roles cannot be locked or expired by the extension. Dropping the extension leaves the schema and administrative roles; remove them separately only after reviewing dependencies. This source-only snapshot has no tagged release or established production acceptance in this catalog.