Skip to content

pg_oidc_validator

OAuth and OIDC token validator for PostgreSQL 18

pg_oidc_validator · OAuth and OIDC token validator for PostgreSQL 18

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
7170pg_oidc_validatorpg_oidc_validator1.1.0SECApache-2.0C++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sL---NoYesYesNonono
oauth_validator_libraries=pg_oidc_validator.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTMIXED1.1.019 18 17 16 15pg_oidc_validator-
RPMPGDG1.1.019 18 17 16 15pg_oidc_validator_$v-
DEBPIGSTY1.1.019 18 17 16 15postgresql-$v-pg-oidc-validator-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/AN/AN/AN/AN/A
el8.aarch64N/AN/AN/AN/AN/A
el9.x86_64PGDG 1.1.0PGDG 1.1.0N/AN/AN/A
el9.aarch64PGDG 1.1.0PGDG 1.1.0N/AN/AN/A
el10.x86_64PGDG 1.1.0PGDG 1.1.0N/AN/AN/A
el10.aarch64PGDG 1.1.0PGDG 1.1.0N/AN/AN/A
d12.x86_64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
d12.aarch64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
d13.x86_64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
d13.aarch64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u22.x86_64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u22.aarch64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u24.x86_64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u24.aarch64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u26.x86_64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
u26.aarch64PIGSTY 1.1.0PIGSTY 1.1.0N/AN/AN/A
PackageVersionOSORGSIZEFile URL
pg_oidc_validator_191.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.9.x86_64.rpm
pg_oidc_validator_191.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.8.x86_64.rpm
pg_oidc_validator_191.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.7.x86_64.rpm
pg_oidc_validator_191.1.0el9.aarch64pgdg462.1 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.9.aarch64.rpm
pg_oidc_validator_191.1.0el9.aarch64pgdg461.8 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.8.aarch64.rpm
pg_oidc_validator_191.1.0el9.aarch64pgdg461.7 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel9.7.aarch64.rpm
pg_oidc_validator_191.1.0el10.x86_64pgdg541.7 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.3.x86_64.rpm
pg_oidc_validator_191.1.0el10.x86_64pgdg541.3 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_191.1.0el10.x86_64pgdg541.3 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_191.1.0el10.aarch64pgdg499.8 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.3.aarch64.rpm
pg_oidc_validator_191.1.0el10.aarch64pgdg499.4 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_191.1.0el10.aarch64pgdg499.4 KiBpg_oidc_validator_19-1.1.0-6PGDG.rhel10.1.aarch64.rpm
postgresql-19-pg-oidc-validator1.1.0d12.x86_64pigsty487.4 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-oidc-validator1.1.0d12.aarch64pigsty476.3 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-oidc-validator1.1.0d13.x86_64pigsty504.6 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-oidc-validator1.1.0d13.aarch64pigsty493.6 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-oidc-validator1.1.0u22.x86_64pigsty536.2 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-oidc-validator1.1.0u22.aarch64pigsty530.4 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-oidc-validator1.1.0u24.x86_64pigsty519.5 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-oidc-validator1.1.0u24.aarch64pigsty515.9 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-oidc-validator1.1.0u26.x86_64pigsty566.6 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-oidc-validator1.1.0u26.aarch64pigsty553.7 KiBpostgresql-19-pg-oidc-validator_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_oidc_validator_181.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.9.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.8.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg499.6 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.7.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg499.2 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel9.8.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg499.2 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel9.7.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg498.4 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel9.8.x86_64.rpm
pg_oidc_validator_181.1.0el9.x86_64pgdg498.5 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel9.7.x86_64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg462.0 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.9.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg462.0 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.8.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg462.0 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel9.7.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg461.6 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel9.8.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg461.6 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel9.7.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg460.8 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel9.8.aarch64.rpm
pg_oidc_validator_181.1.0el9.aarch64pgdg460.8 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel9.7.aarch64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg541.9 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.3.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg541.4 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg541.4 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg541.1 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg541.0 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg540.5 KiBpg_oidc_validator_18-1.1.0-2PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pigsty142.6 KiBpg_oidc_validator_18-1.1.0-1PGSTY.el10.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg540.3 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_181.1.0el10.x86_64pgdg540.3 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_181.0.0el10.x86_64pgdg173.5 KiBpg_oidc_validator_18-1.0.0-1PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_181.0.0el10.x86_64pgdg173.5 KiBpg_oidc_validator_18-1.0.0-1PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_180.2el10.x86_64pgdg173.1 KiBpg_oidc_validator_18-0.2-1PGDG.rhel10.2.x86_64.rpm
pg_oidc_validator_180.2el10.x86_64pgdg173.1 KiBpg_oidc_validator_18-0.2-1PGDG.rhel10.1.x86_64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg500.4 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.3.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg499.5 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg499.5 KiBpg_oidc_validator_18-1.1.0-6PGDG.rhel10.1.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg499.1 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg499.1 KiBpg_oidc_validator_18-1.1.0-5PGDG.rhel10.1.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pigsty129.5 KiBpg_oidc_validator_18-1.1.0-1PGSTY.el10.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg498.3 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_181.1.0el10.aarch64pgdg498.3 KiBpg_oidc_validator_18-1.1.0-1PGDG.rhel10.1.aarch64.rpm
pg_oidc_validator_181.0.0el10.aarch64pgdg155.4 KiBpg_oidc_validator_18-1.0.0-1PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_181.0.0el10.aarch64pgdg155.4 KiBpg_oidc_validator_18-1.0.0-1PGDG.rhel10.1.aarch64.rpm
pg_oidc_validator_180.2el10.aarch64pgdg154.9 KiBpg_oidc_validator_18-0.2-1PGDG.rhel10.2.aarch64.rpm
pg_oidc_validator_180.2el10.aarch64pgdg154.9 KiBpg_oidc_validator_18-0.2-1PGDG.rhel10.1.aarch64.rpm
postgresql-18-pg-oidc-validator1.1.0d12.x86_64pigsty487.5 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-oidc-validator1.1.0d12.aarch64pigsty475.9 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-oidc-validator1.1.0d13.x86_64pigsty504.9 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-oidc-validator1.1.0d13.aarch64pigsty493.7 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-oidc-validator1.1.0u22.x86_64pigsty536.5 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-oidc-validator1.1.0u22.aarch64pigsty530.5 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-oidc-validator1.1.0u24.x86_64pigsty520.2 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-oidc-validator1.1.0u24.aarch64pigsty515.9 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-oidc-validator1.1.0u26.x86_64pigsty566.9 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-oidc-validator1.1.0u26.aarch64pigsty553.9 KiBpostgresql-18-pg-oidc-validator_1.1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_oidc_validator;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_oidc_validator;		# install by package name

pig install pg_oidc_validator -v 19;   # install for PG 19
pig install pg_oidc_validator -v 18;   # install for PG 18

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_oidc_validator';

This extension does not need CREATE EXTENSION DDL command

Usage

Sources:

pg_oidc_validator 1.1.0 is a PostgreSQL 18/19 OAuth validator module that validates JWT access tokens against an OpenID Connect provider. It is a server library with no control file or SQL extension, so do not run CREATE EXTENSION.

Configure the Server

Load the module in postgresql.conf, then restart PostgreSQL:

oauth_validator_libraries = 'pg_oidc_validator'

Add an OAuth rule to pg_hba.conf; the issuer and required scope must match the provider. Use hostssl outside a strictly local test:

hostssl  all  all  127.0.0.1/32  oauth  issuer=https://id.example.com/realms/postgres scope="openid postgres" validator=pg_oidc_validator

Reload PostgreSQL after HBA or validator-setting changes; adding the module to oauth_validator_libraries itself requires a restart.

The default authenticated identity claim is sub. To return another stable string claim for role matching, configure:

pg_oidc_validator.authn_field = 'email'

Version 1.1.0 also provides pg_oidc_validator.discovery_url_override. It changes where discovery metadata and JWKS are fetched without changing the issuer used to validate the JWT iss claim; this is useful when an OIDC provider has different internal and external URLs. Both validator settings are reloadable with SIGHUP.

Without map= in the HBA rule, the selected claim must exactly equal the requested PostgreSQL role. Use a named pg_ident.conf mapping when provider identities and database roles differ; the validator does not create roles.

Connect with libpq

An OAuth-capable libpq client can start the provider’s device authorization flow:

psql 'host=127.0.0.1 dbname=app user=alice oauth_issuer=https://id.example.com/realms/postgres oauth_client_id=postgres-client'

Use oauth_client_secret only when the registered client requires it. The client identifier, requested scope, issuer, and provider configuration must agree.

Provider and Security Boundaries

  • Keycloak must enable the OAuth 2 device flow for command-line clients.
  • Microsoft Entra ID requires a tenant-specific v2 issuer and custom scopes; use the full scope name in pg_hba.conf.
  • Google is not usable through libpq’s built-in device flow, though custom clients may work.
  • Dex does not emit OAuth scopes; an explicitly empty scope="" disables scope validation, which weakens the normal check.
  • The client oauth_issuer must exactly match the HBA issuer and the discovery document. Treat the issuer and any pg_oidc_validator.discovery_url_override endpoint as trusted security boundaries, and require verified TLS for database and provider connections.
  • Token validation does not replace PostgreSQL grants, role membership, or row-level security.
  • Pigsty RPM packages are limited to EL10; DEB packages cover the supported Debian and Ubuntu targets. The 1.1.0 source release supports PostgreSQL 18 and 19; verify package availability separately.

Table reader