Skip to content

orgpasscheck

Password policy enforcement extension for PostgreSQL 16+

orgpasscheck · Password policy enforcement extension for PostgreSQL 16+

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101494orgpasscheckorgpasscheck5.0SECPostgreSQLC

PostgreSQL · 16, 17, 18, 19

Relationships
Requiresplpgsql

Usage

Sources:

orgpasscheck enforces password complexity, dictionary/blacklist, reuse-history and minimum-age rules through check_password_hook. The reviewed PGXN distribution is 5.0.0; the real SQL/control version remains 5.0. PostgreSQL 16 or later is required, with no pgcrypto or pg_trgm dependency.

Enable the Hook and SQL Objects

After installing the matching library, add it to the existing preload list and restart PostgreSQL. As a superuser, create the fixed schema and extension in the database used for password administration.

shared_preload_libraries = 'orgpasscheck'
CREATE SCHEMA orgpasscheck;
CREATE EXTENSION orgpasscheck;
SELECT * FROM orgpasscheck.version_info;
SELECT * FROM orgpasscheck.policy_summary;

The hook is preloaded cluster-wide, but its policy/history tables are local to a database. Password-changing sessions must connect to a database containing those objects; the C code directly accesses them and does not silently skip missing tables. The extension is non-relocatable.

Password Administration

Use orgpasscheck.create_user(p_username, p_password, p_login, p_superuser, p_expiry_days) for creation and orgpasscheck.change_password(p_username, p_password, p_expiry_days) for rotation. Supply secrets through a trusted application with bind parameters. Review statement/parameter logging and client history; plaintext must reach the server and can otherwise appear in logs.

Pre-hashed password input is rejected. Client tools that hash before sending, including psql \password, cannot satisfy this policy by changing password_encryption. Expiration via VALID UNTIL is applied by the SQL wrappers, not the C hook; raw role DDL can bypass that expiry workflow.

The administrative role is orgpasscheck_admin; pg_monitor receives read access to the extension’s tables and views. The SQL helpers are SECURITY DEFINER, and the source uses current_setting('is_superuser') in internal authorization checks. Do not treat the claimed self-service boundary as independently proven: restrict schema/function access to trusted administrators and review effective privileges before exposing wrappers to ordinary users.

Policy and Maintenance

Superusers can change the orgpasscheck.* settings at runtime. Defaults include length 12–256, one uppercase/lowercase/digit/special character each, five history entries, one-day minimum age and 45-day expiry. orgpasscheck.max_length bounds scanning work. Dictionary and blacklist matching is by substring; mixed-case, sequence and username-similarity checks are configurable.

SELECT orgpasscheck.add_blacklist('acmecorp', 'Company name');
SELECT * FROM orgpasscheck.user_password_status;
SELECT * FROM orgpasscheck.expired_passwords;
SELECT * FROM orgpasscheck.rotation_report;

Expiry exemptions use add_expiry_exemption, remove_expiry_exemption, and list_expiry_exemptions in the orgpasscheck schema. Purge helpers manage history and audit retention. History stores salted SHA-256 values; wrapper audit entries record the action, not the password. Protect both tables and backups because they contain security-sensitive metadata.

policy_summary has a PUBLIC SELECT grant; restrict it where policy disclosure is undesirable. A library replacement requires restart. This distribution includes only the 5.0 installation SQL, so a package version change to 5.0.0 does not imply an ALTER EXTENSION ... UPDATE TO '5.0.0' path.

Table reader