Skip to content

Commit a0e13a6

Browse files
authored
PG-2238 - Add the OIDC topic (#930)
This PR reorganizes the authentication methods in Solutions, adding a folder to future proof the authentication methods, and adds the OIDC topic.
1 parent ebde6f7 commit a0e13a6

6 files changed

Lines changed: 121 additions & 5 deletions

File tree

docs/solutions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ Dealing with spatial data? Learn how you can store and manipulate it.
3030

3131
</div><div data-banner markdown>
3232

33-
### :material-account-lock: LDAP authentication
33+
### :material-account-lock: Authentication
3434

35-
Need a central authentication solution? Learn how you can manage users and access control using LDAP directories.
35+
Need centralized authentication? Learn how to integrate PostgreSQL with identity providers such as LDAP directories or OpenID Connect.
3636

37-
[LDAP authentication :material-arrow-right:](ldap.md){.md-button}
37+
[Authentication :material-arrow-right:](solutions/authentication/overview.md){.md-button}
3838

3939
</div>
4040
</div>
File renamed without changes.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# OIDC authentication
2+
3+
[OpenID Connect :octicons-link-external-16:](https://openid.net/developers/how-connect-works/) (or OIDC) authentication allows you to authenticate using tokens issued by an external identity provider. Instead of managing database passwords, you can delegate authentication to centralized identity services.
4+
5+
Percona Distribution for PostgreSQL integrates OIDC authentication using the `pg_oidc_validator` library, which validates OIDC tokens during client authentication.
6+
7+
The library is compatible with any identity provider that implements the OIDC standard.
8+
9+
For configuration details and source code, see the [pg_oidc_validator project :octicons-link-external-16:](https://github.com/Percona-Lab/pg_oidc_validator).
10+
11+
!!! important
12+
OIDC authentication relies on [PostgreSQL OAuth authentication :octicons-link-external-16:](https://www.postgresql.org/docs/current/auth-oauth.html), introduced in PostgreSQL 18.
13+
14+
## When to use OIDC authentication
15+
16+
OIDC authentication is useful when you want to:
17+
18+
* integrate PostgreSQL with an existing single sign-on (SSO) platform
19+
* reduce the need to manage database passwords
20+
* centralize identity management across applications and databases
21+
22+
!!! tip
23+
OIDC authentication simplifies access management for PostgreSQL when using an identity provider that supports OpenID Connect.
24+
25+
## OIDC authentication architecture
26+
27+
OIDC authentication works as follows:
28+
29+
1. The client obtains an access token from an external identity provider
30+
2. The client connects to PostgreSQL using OAuth authentication
31+
3. PostgreSQL forwards the token to the `pg_oidc_validator` module
32+
4. The validator verifies the token signature and claims
33+
5. If validation succeeds, PostgreSQL allows the connection
34+
35+
The following diagram shows how OIDC authentication works between the client, the identity provider, and PostgreSQL:
36+
37+
--8<-- "diagrams/oidc/auth-flow.md"
38+
39+
!!! tip
40+
Before configuring OIDC authentication, ensure that your PostgreSQL deployment can access the identity provider that issues OIDC tokens.
41+
42+
## Set up OIDC authentication
43+
44+
Follow these steps to set up OIDC authentication for your PostgreSQL database.
45+
{.power-number}
46+
47+
1. Install the `pg_oidc_validator` package.
48+
49+
For more information, see the [Quickstart guide](../../installing.md).
50+
51+
Alternatively, you can build the extension from source:
52+
53+
```bash
54+
make USE_PGXS=1 install -j
55+
```
56+
57+
!!! note
58+
A C++23 compiler and standard library is required to build `pg_oidc_validator`.
59+
60+
2. Edit `postgresql.conf` and add the validator library:
61+
62+
```ini
63+
oauth_validator_libraries = 'pg_oidc_validator'
64+
```
65+
66+
!!! note
67+
This setting tells PostgreSQL to load the OIDC validator during startup.
68+
69+
3. Add an OAuth authentication rule to `pg_hba.conf`:
70+
71+
```ini
72+
host all all 192.168.1.0/24 oauth scope="pgadmin-a",issuer=https://oidc.example.com
73+
```
74+
75+
Where:
76+
77+
* `oauth` enables OAuth authentication
78+
* `scope` is the required OIDC scope
79+
* `issuer` is the URL of the OIDC identity provider
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Authentication
2+
3+
Centralized authentication allows you to manage database access using external identity systems instead of local PostgreSQL users.
4+
5+
Percona Distribution for PostgreSQL supports multiple authentication mechanisms that integrate with enterprise identity infrastructure.
6+
7+
## Available authentication methods
8+
9+
### OIDC authentication
10+
11+
Authenticate users using OpenID Connect identity providers.
12+
13+
[OIDC authentication :material-arrow-right:](oidc.md){.md-button}
14+
15+
### LDAP authentication
16+
17+
Use LDAP directories such as OpenLDAP or Active Directory to centrally manage database users.
18+
19+
[LDAP authentication :material-arrow-right:](ldap.md){.md-button}

mkdocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ nav:
6363
- Deployment: solutions/postgis-deploy.md
6464
- Query spatial data: solutions/postgis-testing.md
6565
- Upgrade spatial database: solutions/postgis-upgrade.md
66-
- LDAP authentication:
67-
- ldap.md
66+
- Authentication:
67+
- Overview: solutions/authentication/overview.md
68+
- OIDC authentication: solutions/authentication/oidc.md
69+
- LDAP authentication: solutions/authentication/ldap.md
6870
- Upgrade:
6971
- "Major upgrade": major-upgrade.md
7072
- minor-upgrade.md
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```mermaid
2+
sequenceDiagram
3+
participant Client
4+
participant IdP as Identity Provider (OIDC)
5+
participant PostgreSQL
6+
participant Validator as pg_oidc_validator
7+
8+
Client->>IdP: Request authentication
9+
IdP-->>Client: Return OIDC access token
10+
11+
Client->>PostgreSQL: Connect using OAuth token
12+
PostgreSQL->>Validator: Validate token
13+
Validator-->>PostgreSQL: Token valid / invalid
14+
15+
PostgreSQL-->>Client: Connection allowed or rejected
16+
```

0 commit comments

Comments
 (0)