Skip to content

Commit e89f511

Browse files
authored
ip allowlist (#14)
* feat: allowlist * version
1 parent a423e1b commit e89f511

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: pgdog-control
33
description: PgDog Control
44
type: application
5-
version: 0.2.9
5+
version: 0.2.10
66
appVersion: "v2026-06-09"

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,33 @@ The control plane reads its runtime configuration from a TOML file at `/etc/pgdo
461461

462462
Each subsection below covers one TOML section.
463463

464+
### PgDog API IP Allowlist
465+
466+
`control.config.api.pgdog.ip_allowlist` adds an optional source-IP gate in front of the PgDog machine API endpoints under `/api/v2/*`. It is disabled by default. When enabled, the control plane accepts those requests only when the direct TCP peer address falls inside one of the configured CIDR ranges:
467+
468+
```yaml
469+
control:
470+
config:
471+
api:
472+
pgdog:
473+
ip_allowlist:
474+
enabled: true
475+
allowed_cidrs:
476+
- 10.0.0.0/8
477+
- 172.16.0.0/12
478+
- 192.168.0.0/16
479+
- 127.0.0.0/8
480+
- ::1/128
481+
- fc00::/7
482+
```
483+
484+
If `allowed_cidrs` is omitted, the control plane defaults to private IPv4 ranges, IPv4/IPv6 loopback, and IPv6 ULA. The check intentionally uses the direct TCP peer address and ignores forwarded headers such as `X-Forwarded-For`; configure the CIDRs for the address the control plane actually sees from your ingress, load balancer, sidecar, or PgDog caller.
485+
486+
| Option | Description |
487+
|-|-|
488+
| `api.pgdog.ip_allowlist.enabled` | Enables source-IP checks for `/api/v2/*` PgDog endpoints (bool, default `false`). |
489+
| `api.pgdog.ip_allowlist.allowed_cidrs` | CIDR ranges allowed to call `/api/v2/*`. Invalid CIDRs cause protected requests to be rejected until the config is fixed (list of strings, default private IPv4 ranges, loopback, and IPv6 ULA). |
490+
464491
### Authentication
465492

466493
`control.config.auth` wires up the OAuth-backed login flow for the dashboard. GitHub and Google are supported and can be enabled side by side. At least one needs to be configured, or the dashboard will be **accessible by anyone with the URL**:

templates/configmap.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ metadata:
1818
{{- include "pgdog-control.labels" . | nindent 4 }}
1919
data:
2020
control.toml: |
21+
{{- with $config.api }}
22+
{{- with .pgdog }}
23+
{{- with .ip_allowlist }}
24+
[api.pgdog.ip_allowlist]
25+
{{- if hasKey . "enabled" }}
26+
enabled = {{ .enabled }}
27+
{{- end }}
28+
{{- if hasKey . "allowed_cidrs" }}
29+
allowed_cidrs = [{{ range $i, $cidr := .allowed_cidrs }}{{ if $i }}, {{ end }}{{ $cidr | quote }}{{ end }}]
30+
{{- end }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
34+
2135
{{- with $config.rds }}
2236
[rds]
2337
{{- with .refresh_interval_secs }}

values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ control:
7171
# unset falls back to the Rust-side default. Field names match the TOML
7272
# keys (snake_case) so values are passed through verbatim.
7373
config:
74+
api: {}
75+
# pgdog:
76+
# ip_allowlist:
77+
# # When enabled, restricts /api/v2/* PgDog API endpoints by the
78+
# # direct TCP peer IP address. Forwarded headers are ignored.
79+
# enabled: false
80+
# # Defaults, when omitted:
81+
# # - 10.0.0.0/8
82+
# # - 172.16.0.0/12
83+
# # - 192.168.0.0/16
84+
# # - 127.0.0.0/8
85+
# # - ::1/128
86+
# # - fc00::/7
87+
# allowed_cidrs: []
7488
rds: {}
7589
# refresh_interval_secs: 60
7690
# Experimental: do not enable in production yet.

0 commit comments

Comments
 (0)