Skip to content

deploy/sbx: write SH_TRUSTED_PROXY_HOPS for an OIDC deployment - #946

Merged
webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/i937-sbx-proxy-hops
Nov 20, 2026
Merged

webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/i937-sbx-proxy-hops

Conversation

@webchang

Copy link
Copy Markdown
Member

Summary

deploy/sbx/setup.sh never wrote SH_TRUSTED_PROXY_HOPS. On a sandbox deployment with SBX_IDENTITY_PROVIDER=oidc, the control plane therefore kept its default of 0 behind the sbx-api Route and keyed every OIDC login start by the router's own address: the whole deployment shared one per-source bucket (MAX_PENDING_LOGINS_PER_SOURCE, 20), the case #716 fixed for deploy/k8s.

Closes #937

What changes

  • With SBX_IDENTITY_PROVIDER=oidc, setup.sh writes two keys into moca-settings, which deploy/k8s/base/control-plane.yaml already reads as optional keys:
    • SH_TRUSTED_PROXY_HOPS from the new SBX_TRUSTED_PROXY_HOPS, default 1 (the Route pins haproxy.router.openshift.io/set-forwarded-headers: append, as deploy/k8s/setup.sh assumes);
    • SH_OIDC_MAX_PENDING_PER_SOURCE from the new SBX_OIDC_MAX_PENDING_PER_SOURCE, empty by default: the control plane's countEnv treats '' as its default (packages/control-plane/src/main.ts:115-117), so an empty value means 20 at boot; 0 turns the bound off.
  • Both are refused before anything is applied unless a whole number of 0 to 6 digits, matching deploy/k8s/setup.sh's valid_count (the control plane refuses to boot on anything else).
  • On the GitHub path, either knob set is reported (WARNING: … is set but ignored: the identity provider is github) and written nowhere.
  • A GitHub deployment's moca-settings is unchanged, on purpose: nothing reads the client address there (the per-source bound is the OIDC login start's, packages/control-plane/src/oidc.ts), so writing the hop count would only move every GitHub deployment's settings hash. Its pods don't roll on upgrade.
  • Switching a deployment to oidc adds the two keys with the rest of the identity block: one control-plane roll, as the switch already causes.
  • Set both in the env file: setup.sh owns moca-settings and rewrites it whole, so a hand edit is overwritten at the next run (the install page says so). A sticky keep-the-stored-value convention, as deploy/k8s/setup.sh has, would be a separate change.
  • Docs: setup.sh's header, the install page's optional inputs, the configuration reference's SH_TRUSTED_PROXY_HOPS row and the OIDC guide.

Tests

deploy/sbx/tests/setup.test.sh:

  • an oidc run writes SH_TRUSTED_PROXY_HOPS=1 and an empty SH_OIDC_MAX_PENDING_PER_SOURCE;
  • with SBX_TRUSTED_PROXY_HOPS=2 and SBX_OIDC_MAX_PENDING_PER_SOURCE=0, both are written as given, and the rendered control plane reads both from moca-settings;
  • a non-numeric hop count and a negative bound are refused, each naming the variable;
  • a github run writes neither key and warns about neither; with both knobs set, it warns about each and still writes neither.

Before the fix, the refusal check fails first (SBX_TRUSTED_PROXY_HOPS=one is accepted) and, with validation alone, the oidc check fails (SH_TRUSTED_PROXY_HOPS not written). After it, the whole suite passes. scripts/check-doc-links.py: 0 broken.

Assisted-By: Claude Code

…bound on an oidc deployment

deploy/sbx/setup.sh never wrote SH_TRUSTED_PROXY_HOPS, so on an oidc deployment behind the
sbx-api Route the control plane kept its default of 0 and keyed every OIDC login start by the
router's own address: the whole deployment shared one per-source bucket
(MAX_PENDING_LOGINS_PER_SOURCE, 20), the case rossoctl#716 fixed for deploy/k8s.

With SBX_IDENTITY_PROVIDER=oidc, setup.sh now writes SH_TRUSTED_PROXY_HOPS (SBX_TRUSTED_PROXY_HOPS,
default 1: the Route pins set-forwarded-headers: append) and SH_OIDC_MAX_PENDING_PER_SOURCE
(SBX_OIDC_MAX_PENDING_PER_SOURCE, empty: the control plane's default) into moca-settings, which the
base already reads as optional keys. Both are refused up front unless a whole number of 0 to 6
digits, as deploy/k8s/setup.sh does. A GitHub deployment's settings are unchanged (GitHub logins
have no per-source bound), so its settings hash does not move.

Tests (deploy/sbx/tests/setup.test.sh): an oidc run writes 1 and an empty bound by default; set
values are written as given and the rendered control plane reads both from moca-settings; bad
values are refused; a github run writes neither.

Closes rossoctl#937

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 20, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — deploy/sbx: write SH_TRUSTED_PROXY_HOPS for an OIDC deployment

Right diagnosis: the hop count defaults to 0, so behind the sbx-api Route every login start keyed on the router's own address and the whole deployment shared one 20-slot bucket — #716's fix never reached the sbx profile.

  • The default 1 matches the Route that serves the login start: deploy/k8s/overlays/ocp-sbx/api-route.yaml pins haproxy.router.openshift.io/set-forwarded-headers: append (ocp-combined's moca-api does too), which is exactly the trust the count relies on. clientSource ignores a header with fewer entries than the count and keeps the socket peer, so an unusual topology (a port-forward, a different proxy) degrades to today's behaviour rather than to an address a caller can pick.
  • The empty bound is the control plane's default, not a zero: the base already reads both keys as optional moca-settings entries (deploy/k8s/base/control-plane.yaml), and countEnv returns the default for '' (main.ts:115-117), so SH_OIDC_MAX_PENDING_PER_SOURCE= is 20 and 0 still turns the bound off.
  • The validation is deploy/k8s/setup.sh's valid_count verbatim (0 to 6 digits, no leading zeros), deliberately stricter than countEnv, and it refuses before anything is applied; the boot-time refusal is the backstop for a value written some other way.
  • GitHub is untouched on purpose: nothing is written, so moca-settings stays byte-identical and SETTINGS_HASH — which hashes the moca array in ensure_settings — does not move, so its pods do not roll. The warning loop is the right compromise: an operator who set an oidc-only knob on a GitHub deployment is told rather than silently ignored.
  • Whole-rewrite versus sticky is stated in the body and in the install row ("set both in the env file"), so a hand edit being overwritten at the next run is documented rather than surprising; that is the right call for a script that owns moca-settings.
  • Tests pin the behaviour that matters: both malformed values in the shared refusal table; an oidc run writing 1 and ''; the 2/0 run writing them as given with the rendered control plane reading both from moca-settings; and a GitHub run warning per knob while writing neither, with the default GitHub run neither warning nor changing the configmap.

One non-blocking gap: docs/operate/day-2/upgrades.md has no entry. This changes what a re-run of setup.sh writes on an OIDC deployment (two new keys, one control-plane roll), which is that page's rule 5 section, and the k8s half of #716 has its bullet there. A short one would tell operators the roll is expected and that the login bound now keys on the real client address.

CI 17/17 green. Author: webchang (MEMBER — maintainer). One commit, signed off.

@webchang
webchang merged commit 02c7347 into rossoctl:main Nov 20, 2026
17 checks passed
@pdettori pdettori added this to the v0.11.0 milestone Nov 20, 2026
webchang added a commit to webchang/moca that referenced this pull request Nov 20, 2026
Carries rossoctl#941-rossoctl#946, rossoctl#948, rossoctl#950 and rossoctl#338's rossoctl#949/rossoctl#951 (API 1.33.0).
One conflict: docs/operate/sandbox-service/install.md's settings
table; upstream's table kept (its rossoctl#945 SBX_STORAGE_CLASS wording,
the OIDC and proxy-hop rows) plus the fork's SBX_GATE_RECORD_SCHEMA
row. The fork-only set is unchanged: the same 30 files.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy/sbx: setup.sh never writes SH_TRUSTED_PROXY_HOPS, so OIDC logins behind the router share one per-source bucket

3 participants