Skip to content

Client source and IP restrictions

Last updated: 2026-11-22T07:30:00-03:00 (UTC-3)

Source controls add an independent network ceiling to normal identity, route, model, team and budget authorization. They never grant access on their own. They default to off, with no trusted proxies, no administrative restriction and unrestricted key source lists.

features:
source_ip_controls: false
client_ip_logging: false
server:
trusted_proxies: []
forwarded_for_max_hops: 32
forwarded_for_max_bytes: 4096
admin:
allowed_source_cidrs: []
keys:
- id: local-app
principal: example-app
team: platform
kind: service_account
sha256_env: GATEWAY_CLIENT_KEY_SHA256
allowed_models: [chat-default]
scopes: [route:models, route:chat]
allowed_source_cidrs: []

These are the relevant portions of a complete gateway configuration, not a replacement for its providers, models and storage. Supply credentials through the normal operator Secret references.

Setting Default and effect
source_ip_controls false; boot operator flag. Enabling requires a reviewed configuration and rollout.
client_ip_logging false; separate runtime operator flag, requiring source controls. Enables only canonical client IP in structured stdout request logs and OTLP.
server.trusted_proxies []; trust no forwarded identity. Include only the actual ingress/load-balancer CIDRs; universal /0 trust is refused.
server.forwarded_for_max_hops 32; raw 0 selects default, accepted 1–128.
server.forwarded_for_max_bytes 4096; raw 0 selects default, accepted 64–16384 total bytes.
admin.allowed_source_cidrs []; no administrative source ceiling. Nonempty applies only when the source flag is on. Read-only in the startup inspector as admin.allowed_source_cidrs of infrastructure.source_ip.
keys[].allowed_source_cidrs []; no key source ceiling. Managed keys have the same optional policy through the API and console.

Each CIDR list has at most 64 literal prefixes. Use /32 for one IPv4 address or /128 for one IPv6 address. Host bits normalize to their network; canonical duplicates, DNS names, ports, zones and mapped-IPv6 prefixes are refused. IPv4-mapped peer/header addresses normalize to IPv4, so configure their IPv4 prefix. Empty lists do not disable other authentication or authorization.

New policy fields reject nulls and scalar coercion. Startup trust/admin ranges and forwarding budgets appear in the privileged config API and Settings & sources → Infrastructure with their source/default and restart scope. They are read-only startup inspection, not a generic host-network writer. Scoped users do not receive infrastructure through their filtered config view. The summary origin is yaml for explicitly declared feature switches or nonempty/nonzero startup source inputs, otherwise default; it is not a per-field declaration ledger. Empty arrays and zero-selects-default limits can report default. Managed key policy editing is separate and runtime-safe.

The gateway captures the transport peer and source once. An untrusted peer cannot replace its source with a header. This profile reads only X-Forwarded-For from an explicitly trusted immediate peer; it does not use X-Real-IP, RFC Forwarded, DNS lookup, proxy protocol, or forwarded host/scheme as alternate identity proof.

For a trusted peer, a missing XFF uses the transport peer. A supplied XFF must be a bounded, fully valid list of plain IP literals. Multiple header lines retain their order. The gateway walks right to left through configured trusted ranges and selects the first untrusted hop; if every supplied hop is trusted, it selects the leftmost. Empty/unknown/quoted/port/zone/non-IP entries and exceeded limits are invalid, rather than a fallback grant from the proxy’s address.

For example, with only the actual 10.0.0.0/24 proxy subnet trusted:

Transport peer XFF Selected source
198.51.100.9 203.0.113.7 198.51.100.9; untrusted peer’s header ignored
10.0.0.2 203.0.113.7 203.0.113.7
10.0.0.2 203.0.113.7, 198.51.100.9 198.51.100.9; forged leftmost value cannot grant access
10.0.0.2 203.0.113.7, 10.0.0.3 203.0.113.7
10.0.0.2 Absent 10.0.0.2, with peer provenance

The ingress must strip or correctly append client-supplied forwarding data, and the deployment must prevent clients bypassing that ingress from a trusted range. A header is not cryptographic identity. Allowing a proxy’s address in a key/admin policy also allows requests whose only proven source is that proxy; do not mistake that for an individual user’s address.

Malformed trusted source data is refused on protected paths with 400 invalid_client_source; an applicable CIDR miss is 403 source_ip_forbidden. Responses never echo the supplied chain or selected IP. Health/probes, metrics, public documentation and public research stay outside the administrative source ceiling.

The administrative ceiling applies before session/token lookup to /ui and its assets, both administrative API prefixes, SCIM, SSO browser callbacks and logout/backchannel routes. It preserves SCIM error envelopes. Include legitimate IdP backchannel and provisioning service source ranges as well as administrator sources; those callbacks have no implicit exemption. All existing CSRF, token, trust, role, membership and replay controls still apply.

Key source checks run before team/RPM/quota/upstream admission and apply to declared keys, managed bearer keys, inference JWT mappings and realtime ephemeral credentials. Native PostgreSQL returns the policy with the identity in the same lookup, even for an unrestricted list. A managed reader without the required policy proof fails closed with 503 while enforcement is on; absent metadata is never silently treated as unrestricted. This delivery validates the default PostgreSQL authority, not unqualified optional adapters.

Managed positive authentication caching is bypassed whenever source controls are enabled, so a cached unrestricted snapshot cannot hide a newly tightened policy. The normal database/revocation requirements remain. Editing a revoked key’s policy does not reactivate its credential. Credential rotation preserves the parent source ceiling; source-policy changes use an independent version and audit. Already-admitted requests have their normal captured authority semantics; this is not a retroactive cancellation mechanism.

Derived in-process calls inherit the proven parent source. Already-admitted background work with no human source has an explicit internal network-check boundary and no invented localhost client address. An ordinary internal-origin marker alone does not grant an exemption. The source is not reconstructed from stripped headers or a synthetic loopback address.

When source controls are on, fixed/forwarded/custom-auth provider settings cannot use X-Forwarded-For, X-Real-IP or Forwarded, and outbound protections also reject or remove them if validation is bypassed. This does not change the separate public host/scheme contract or other permitted provider headers.

Create a key with an optional source list, or open its source-policy editor in Virtual keys. Empty explicitly means unrestricted source. The editor distinguishes staged policy from active enforcement and does not change routes, models or other ceilings. YAML key policies remain read-only in the console/API; change them in YAML and roll out. Browsers normalize the special IDs . and .. as URL segments even when escaped; the console inspects these policies from its already-authorized configuration projection, without constructing a key-policy URL or adding a writer.

Method Endpoint Purpose
GET /api/v1/admin/keys/{id}/source-cidrs Normalized policy, source, independent version and operational enforcement flag
PUT Same Complete versioned replacement; [] clears only the source ceiling

Reads require existing key-read permission and current ownership/team scope. Writes require a global administrator or active current team administrator with key-manage authority, checked again in the transaction. Plain-member key actions do not delegate this edit. A per-key ceiling is not a global team perimeter; a scoped administrator already able to create keys retains the documented scoped writer.

Use an existing authenticated same-origin session and its CSRF token:

Terminal window
BASE_URL='http://localhost:8080'
: "${COOKIE_JAR:?Set the authenticated console cookie file}"
: "${CSRF_TOKEN:?Set the session CSRF token}"
: "${GATEWAY_KEY_ID:?Select an existing managed key ID}"
SNAPSHOT=$(mktemp)
trap 'rm -f "$SNAPSHOT"' EXIT
curl --fail-with-body -sS -b "$COOKIE_JAR" \
"$BASE_URL/api/v1/admin/keys/$GATEWAY_KEY_ID/source-cidrs" > "$SNAPSHOT"
python3 -c 'import json,sys; s=json.load(open(sys.argv[1])); json.dump({"version":s["version"],"allowed_source_cidrs":["203.0.113.0/24"]},sys.stdout)' "$SNAPSHOT" | \
curl --fail-with-body -sS -b "$COOKIE_JAR" -X PUT \
-H "X-CSRF-Token: $CSRF_TOKEN" -H 'Content-Type: application/json' \
--data-binary @- "$BASE_URL/api/v1/admin/keys/$GATEWAY_KEY_ID/source-cidrs"

Replace the example documentation range with the intended source network. The policy can be staged while enforcement is off. A stale policy version or YAML-owned write returns409; invalid input is400. Reload/review after conflict or uncertain storage failure. The editor clears drafts and fences late replies when identity, role, team, key, session or operational flag changes.

client_ip_logging is separate consent for new canonical client IP telemetry. Structured stdout request records use client_ip; OTLP uses the OpenTelemetry client.address semantic convention. Neither raw forwarding chains nor client IP metric labels are emitted. Internal workers with no parent source do not acquire a fake address. Opt-out at a fresh boundary preserves private authorization source but removes new telemetry collection.

This profile does not persist request IP in the SQL log explorer, UsageEvent, durable receipts or the financial ledger. External stdout/OTLP collectors own their retention and access policy; request/trace IDs link their records to authorized gateway metadata. Existing peer-based security diagnostics and stored CIDR authorization configuration are distinct, so disabling collection does not mean there are no IP addresses anywhere. Persisted source investigation with its own retention is the separate client_source_metadata profile below.

client_source_metadata (off by default, operator control; requires request_logs and source_ip_controls) keeps the canonical client address of each inference request so authorized administrators can investigate by source later. It is separate consent from client_ip_logging; either can be on without the other.

features:
source_ip_controls: true
request_logs: true
client_source_metadata: true
client_source_metadata:
retention_days: 7 # 1-30; 0 or omitted means 7
read: global # global: global admin and viewer roles only; team: also team roles with logs:read, for their teams
Setting Default Bounds and effect
features.client_source_metadata false Collection and reads. Off: nothing new is stored and nothing is read; stored addresses still expire and can still be erased.
client_source_metadata.retention_days 7 1 to 30. Each address expires that many days after it was stored (database clock); expired addresses are never read and are deleted every minute in batches by every replica. Changing it affects new addresses only; restart to apply.
client_source_metadata.read global global or team. Restart to apply.

What is stored, and where:

  • One canonical address per request: the same value the source policy decided (the transport peer, or the nearest untrusted hop of a trusted X-Forwarded-For chain). Forwarding chains, ports and headers are never stored; a request whose source was invalid or internal stores nothing.
  • Its own table (gateway_request_client_sources, migration 130), keyed by request ID, trace ID and key. The first observation of a request wins. Usage events, durable receipts, the ledger and their fingerprints never carry the address, so retention and erasure never touch financial evidence; metrics never get an address label.
  • A client that reuses the same request ID and trace ID under one key shares one stored address: the first observation wins, and the journey shows it against the latest record.
  • Addresses are not deleted with the usage rows they describe (metadata retention, team purge); they still expire after retention_days at most, or can be erased by CIDR. The purge drains up to 40 seconds of each minute per replica and logs client_source_retention_backlog when it could not finish.
  • The address is written after the request’s usage record and only when that write succeeded; a failure is logged as client_source_record_failed and never affects the request. Only the main inference usage path records it.

Where it is read (all through the request log’s team authorization):

  • Request logs filter client_ip: one address or CIDR of at least /8 (IPv4) or /32 (IPv6), applied inside the query before pagination: GET /api/v1/admin/logs?client_ip=198.51.100.0/24. A role that may not read addresses gets 404 feature_disabled. The console shows the Client address filter to global roles.
  • Request journey (request_journey): the received stage shows Client address (verified).
  • CSV export adds a client_ip column for a role that may read addresses.

Erasure: a global administrator with retention:manage deletes the addresses of one request or inside one address/CIDR, also with the flag off. Usage records are unchanged. The erasure is audited as client_source.erase with the count; the audit names the request ID but never repeats an erased address.

Terminal window
curl -sS -b "$COOKIE_FILE" -H "X-CSRF-Token: $CSRF" -H 'Content-Type: application/json' \
-d '{"client_ip":"198.51.100.0/24"}' "$BASE_URL/api/v1/admin/client-sources/erase"
# {"deleted":2}

The console’s request journey offers Erase client address to global administrators. Data governance → Client addresses shows client_source_metadata.retention_days and client_source_metadata.read (the effective values of client_source_metadata in GET /api/v1/admin/config), read-only.

Upgrade: migration 130 creates the table. Upgrade every replica before enabling the flag; an old replica neither stores nor erases addresses.

Migration 118 adds only managed-key policy/version fields, not client-IP telemetry. Upgrade every replica before activating enforcement; old processes cannot enforce the new policy. Review ingress trust and include recovery/IdP sources before enabling the boot flag. Keep operator access to YAML/Secrets and the deployment control plane: network lockout cannot be repaired through the blocked console. Validate and roll back the startup policy through the operator’s deployment procedure. This does not provision an ingress, firewall, proxy or cloud network.

See access control, managed credential cache, telemetry, security and deployment operations.

Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.

Route What it does
POST /api/v1/admin/client-sources/erase Deletes the stored client addresses of one request, or every address inside one IP or CIDR; works with the flag off
PUT /api/v1/admin/keys/{id}/source-cidrs Replaces a managed key’s allowed client networks at its current policy version

m7gtwcontact@m7gtw.com