Skip to content

Create enforcement.md - Encryption Enforcement topic #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: release-17.5.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
edbf109
initial encryption enforcement doc
Andriciuc Jun 9, 2025
a2a4ed9
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 9, 2025
4ceee41
Update enforcement.md
Andriciuc Jun 9, 2025
127cffa
Merge branch 'docs-create-enforcement' of https://github.com/percona/…
Andriciuc Jun 9, 2025
78376c3
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 9, 2025
5e8360f
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 10, 2025
469f1de
Update enforcement.md
Andriciuc Jun 10, 2025
a47f922
Merge branch 'docs-create-enforcement' of https://github.com/percona/…
Andriciuc Jun 10, 2025
c63c721
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 10, 2025
dcb6259
Update enforcement.md
Andriciuc Jun 10, 2025
cbdf83e
Update enforcement.md
Andriciuc Jun 10, 2025
6d27b14
Update enforcement.md
Andriciuc Jun 10, 2025
d3b6174
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 11, 2025
73bb82d
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 11, 2025
04f6276
Update enforcement.md
Andriciuc Jun 11, 2025
d2ab825
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 12, 2025
f16cdb0
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 13, 2025
1a3b276
Merge branch 'TDE_REL_17_STABLE' into docs-create-enforcement
Andriciuc Jun 16, 2025
3cbbf9a
Merge branch 'release-17.5.2' into docs-create-enforcement
Andriciuc Jun 16, 2025
1cb64f1
Merge branch 'release-17.5.2' into docs-create-enforcement
Andriciuc Jun 18, 2025
bd5f2ce
Updated enforcement with examples and variables with link
Andriciuc Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions contrib/pg_tde/documentation/docs/how-to/enforcement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Encryption Enforcement

For `pg_tde`, encryption enforcement ensures that only encrypted storage is allowed for specific operations, tables, or the entire database. It prevents the accidental creation of unencrypted tables or indexes in environments where encryption is required for compliance, security, or policy enforcement.

## What does enforcement do?

When enabled, encryption enforcement:

* Prevents creation of unencrypted tables or indexes
* Enforces consistent encryption usage across tenants, databases, or users
* Can be scoped globally, per database, or per role

## Enforce encryption usage

Use the following techniques to enforce the secure use of `pg_tde`.

### 1. Enforce encryption across the server

To enforce encryption cluster-wide, set the [`pg_tde.enforce_encryption`](../variables.md/#pg_tdeenforce_encryption) variable in `postgresql.conf`:

```ini
pg_tde.enforce_encryption = on
```

This ensures that no user, including superusers, can create unencrypted tables unless they explicitly override the variable in a session (see below).

### 2. Enforce encryption for a specific database

To apply encryption enforcement only within a specific database, run:

```sql
ALTER DATABASE example_db SET pg_tde.enforce_encryption = on;
```

This ensures encryption is enforced **only** when connected to that database.

### 3. Enforce encryption for a specific user

You can also enforce encryption on a per-user basis, run:

```sql
ALTER USER example_user SET pg_tde.enforce_encryption = on;
```

This ensures that the user `example_user` cannot create unencrypted tables, regardless of which database they connect to.

### Override enforcement for trusted sessions

Superusers (such as DBAs) can override the variable at the session level:

```sql
SET pg_tde.enforce_encryption = off;
```

This allows temporary creation of unencrypted tables in special cases, such as:

* Loading trusted, public reference datasets
* Benchmarking and test environments
* Migration staging before re-encryption

!!! note
While superusers can disable enforcement in their session, they must do so explicitly. Enforcement defaults remain active to protect from accidental misconfiguration.
26 changes: 13 additions & 13 deletions contrib/pg_tde/documentation/docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Similarly, `ALTER TABLE <x> SET ACCESS METHOD` is only allowed, if the access me

Other DDL operations are still allowed. For example other `ALTER` commands are allowed on unencrypted tables, as long as the access method isn't changed.

You can set this variable at the following levels:
You can set this variable at the following levels:

* global - for the entire PostgreSQL cluster.
* database - for specific databases.
* user - for specific users.
* session - for the current session.
* global - for the entire PostgreSQL cluster
* database - for specific databases
* user - for specific users
* session - for the current session

Setting or changing the value requires superuser permissions.
Setting or changing the value requires superuser permissions. For examples, see the [Encryption Enforcement](how-to/enforcement.md) topic.

## pg_tde.inherit_global_providers

Expand All @@ -52,12 +52,12 @@ If disabled, functions that change the key providers can only work with database

In this case, the default principal key, if set, is also disabled.

You can set this variable at the following levels:
You can set this variable at the following levels:

* global - for the entire PostgreSQL cluster.
* database - for specific databases.
* user - for specific users.
* session - for the current session.
* global - for the entire PostgreSQL cluster
* database - for specific databases
* user - for specific users
* session - for the current session


Setting this variable doesn't affect existing uses of global keys. It only prevents the creation of new principal keys using global providers.
!!! note
Setting this variable doesn't affect existing uses of global keys. It only prevents the creation of new principal keys using global providers.
1 change: 1 addition & 0 deletions contrib/pg_tde/documentation/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ nav:
- "pg_checksums": command-line-tools/pg-tde-checksums.md
- "Uninstall pg_tde": how-to/uninstall.md
- "Configure Multi-tenancy": how-to/multi-tenant-setup.md
- "Encryption Enforcement": how-to/enforcement.md
- "Decrypt an Encrypted Table": how-to/decrypt.md
- faq.md
- "Release Notes":
Expand Down