Skip to content

Commit 8d3c6dc

Browse files
committed
PGWire OIDC integration
1 parent faa151d commit 8d3c6dc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

documentation/configuration-utils/_oidc.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,9 @@
9090
"acl.oidc.cache.ttl": {
9191
"default": 30000,
9292
"description": "User info cache entry TTL (time to live) in milliseconds, default value is 30 seconds. For improved performance QuestDB caches user info responses for each valid access token, this settings drives how often the access token should be validated and the user info updated."
93+
},
94+
"acl.oidc.pg.token.as.password.enabled": {
95+
"default": "false",
96+
"description": "When enabled, the PGWire endpoint supports OIDC authentication. The OAuth2 token should be sent in the password field, while the username field should contain the string `_sso`, or left empty if that is an option."
9397
}
9498
}

documentation/operations/openid-connect-oidc-integration.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,30 @@ with Sender.from_conf(conf) as sender:
576576
sender.dataframe(df, table_name="foo", at="ts")
577577
```
578578

579+
## OIDC for the PGWire endpoint
580+
581+
If ROPC is not an option, we can still authenticate via OIDC on the PGWire endpoint.
582+
However, in this case the client's responsibility to source the token required for authentication.
583+
This method works wherever a Postgres client library is available, including jupyter notebooks.
584+
585+
Token authentication for the PGWire endpoint should be enabled by adding the `acl.oidc.pg.token.as.password.enabled=true` setting to the server configuration.
586+
587+
The token should be sent in the password field, while the username field should contain the string `_sso`, or left empty if that is an option:
588+
589+
```python
590+
import psycopg as pg
591+
592+
token = "token_requested_from_the_oauth2_provider"
593+
594+
conn_str = f"user=_sso password={token} host=localhost port=8812 dbname=qdb"
595+
with pg.connect(conn_str, autocommit=True) as connection:
596+
with connection.cursor() as cur:
597+
cur.execute('select current_user()')
598+
records = cur.fetchall()
599+
for row in records:
600+
print(row)
601+
```
602+
579603
## User permissions
580604

581605
QuestDB requires additional user information to be able to construct the user's

0 commit comments

Comments
 (0)