pgextwlist

pgextwlist

pgextwlist : PostgreSQL Extension Whitelisting

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
7390
pgextwlist
pgextwlist
1.19
SEC
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sL---
No
Yes
Yes
No
no
no
Relationships
See Also
ddlx
pgdd
pg_permissions
adminpack
pgaudit
set_user
pg_catcheck
noset

missing pg18 on el

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
MIXED
1.19
18
17
16
15
14
pgextwlist-
RPM
PIGSTY
1.19
18
17
16
15
14
pgextwlist_$v-
DEB
PGDG
1.19
18
17
16
15
14
postgresql-$v-pgextwlist-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
el8.aarch64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
el9.x86_64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
el9.aarch64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
el10.x86_64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
el10.aarch64
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
PIGSTY 1.19
d12.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d12.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d13.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d13.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u22.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u22.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u24.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u24.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19

Source

pig build pkg pgextwlist;		# build rpm

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 pgextwlist;		# install via package name, for the active PG version

pig install pgextwlist -v 18;   # install for PG 18
pig install pgextwlist -v 17;   # install for PG 17
pig install pgextwlist -v 16;   # install for PG 16
pig install pgextwlist -v 15;   # install for PG 15
pig install pgextwlist -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgextwlist';

This extension does not need CREATE EXTENSION DDL command

Usage

pgextwlist: PostgreSQL extension whitelisting

pgextwlist implements extension whitelisting: only explicitly allowed extensions can be installed, and whitelisted extensions are installed with superuser privileges even when requested by non-superusers.

Configuration

Add to postgresql.conf:

local_preload_libraries = 'pgextwlist'
extwlist.extensions = 'hstore,cube,pg_stat_statements'

Or per-role:

ALTER ROLE adminuser SET extwlist.extensions = 'pg_stat_statements, postgis';
ParameterDescription
extwlist.extensionsComma-separated list of whitelisted extensions
extwlist.custom_pathFilesystem path for custom pre/post scripts

Behavior

Non-superusers can install whitelisted extensions:

-- Allowed (hstore is whitelisted)
CREATE EXTENSION hstore;

-- Blocked (not whitelisted)
CREATE EXTENSION earthdistance;
-- ERROR: extension "earthdistance" is not whitelisted

Operations CREATE EXTENSION, DROP EXTENSION, ALTER EXTENSION ... UPDATE, and COMMENT ON EXTENSION are run as superuser for whitelisted extensions.

Custom Scripts

Place scripts in ${extwlist.custom_path}/extname/:

ScriptWhen
before--1.0.sqlBefore installing version 1.0
before-create.sqlBefore CREATE (fallback)
after--1.0.sqlAfter installing version 1.0
after-create.sqlAfter CREATE (fallback)
before-update.sql / after-update.sqlAround ALTER EXTENSION UPDATE
before-drop.sql / after-drop.sqlAround DROP EXTENSION

Custom scripts support template variables: @extschema@, @current_user@, @database_owner@.

Last updated on