Repository navigation
deploy/sbx: write SH_TRUSTED_PROXY_HOPS for an OIDC deployment - #946
Merged
Merged
Conversation
…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]>
ingpaolodettori-dev
approved these changes
Nov 20, 2026
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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.yamlpinshaproxy.router.openshift.io/set-forwarded-headers: append(ocp-combined'smoca-apidoes too), which is exactly the trust the count relies on.clientSourceignores 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-settingsentries (deploy/k8s/base/control-plane.yaml), andcountEnvreturns the default for''(main.ts:115-117), soSH_OIDC_MAX_PENDING_PER_SOURCE=is 20 and0still turns the bound off. - The validation is
deploy/k8s/setup.sh'svalid_countverbatim (0 to 6 digits, no leading zeros), deliberately stricter thancountEnv, 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-settingsstays byte-identical andSETTINGS_HASH— which hashes themocaarray inensure_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
1and''; the2/0run writing them as given with the rendered control plane reading both frommoca-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
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deploy/sbx/setup.shnever wroteSH_TRUSTED_PROXY_HOPS. On a sandbox deployment withSBX_IDENTITY_PROVIDER=oidc, the control plane therefore kept its default of 0 behind thesbx-apiRoute 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 fordeploy/k8s.Closes #937
What changes
SBX_IDENTITY_PROVIDER=oidc,setup.shwrites two keys intomoca-settings, whichdeploy/k8s/base/control-plane.yamlalready reads as optional keys:SH_TRUSTED_PROXY_HOPSfrom the newSBX_TRUSTED_PROXY_HOPS, default1(the Route pinshaproxy.router.openshift.io/set-forwarded-headers: append, asdeploy/k8s/setup.shassumes);SH_OIDC_MAX_PENDING_PER_SOURCEfrom the newSBX_OIDC_MAX_PENDING_PER_SOURCE, empty by default: the control plane'scountEnvtreats''as its default (packages/control-plane/src/main.ts:115-117), so an empty value means 20 at boot;0turns the bound off.deploy/k8s/setup.sh'svalid_count(the control plane refuses to boot on anything else).WARNING: … is set but ignored: the identity provider is github) and written nowhere.moca-settingsis 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.oidcadds the two keys with the rest of the identity block: one control-plane roll, as the switch already causes.setup.shownsmoca-settingsand 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, asdeploy/k8s/setup.shhas, would be a separate change.setup.sh's header, the install page's optional inputs, the configuration reference'sSH_TRUSTED_PROXY_HOPSrow and the OIDC guide.Tests
deploy/sbx/tests/setup.test.sh:SH_TRUSTED_PROXY_HOPS=1and an emptySH_OIDC_MAX_PENDING_PER_SOURCE;SBX_TRUSTED_PROXY_HOPS=2andSBX_OIDC_MAX_PENDING_PER_SOURCE=0, both are written as given, and the rendered control plane reads both frommoca-settings;Before the fix, the refusal check fails first (
SBX_TRUSTED_PROXY_HOPS=oneis accepted) and, with validation alone, the oidc check fails (SH_TRUSTED_PROXY_HOPSnot written). After it, the whole suite passes.scripts/check-doc-links.py: 0 broken.Assisted-By: Claude Code