Skip to content

fix(configure): preserve unrelated gateway auth policy across reconfiguration - #131035

Merged
steipete merged 2 commits into
mainfrom
steipete/configure-auth-preserve
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/configure-auth-preserve

Conversation

@steipete

Copy link
Copy Markdown
Contributor

REVIEW REQUIRED — gateway security configuration. Prepared by the auto-QA campaign; intentionally left as a draft for maintainer review, not autonomous landing.

What Problem This Solves

openclaw configure --section gateway silently deleted existing Gateway auth policies: buildGatewayAuthConfig() rebuilt auth from an empty object preserving only allowTailscale, so an operator's explicitly configured rateLimit and identityScopes vanished on any pass through the wizard — even selecting the same auth mode. Startup then fell back to default rate limits (src/gateway/server-runtime-state-prepare.ts:361) and verified identities lost their grants (ws-connection/connect-admission.ts:105). The empty-base defect ships in stable v2026.7.1-2 (there affecting rateLimit; identityScopes postdates that schema). Classic and non-interactive onboarding already spread the existing auth block — configure was the divergent owner.

Why This Change Was Made

The builder now starts from a shallow copy of existing auth, deletes mode-owned fields, and applies the selected mode — adopting the siblings' independent-policy preservation while keeping configure's existing credential cleanup (which the siblings lack). The special-case allowTailscale branch is deleted. Net −1 production line. Complete field classification (from zod-schema.gateway.ts:116): mode/token/password/trustedProxy are mode-owned (replaced; stale mode credentials removed), allowTailscale/identityScopes/rateLimit are independent policy (preserved verbatim, including explicit false). Fresh configs invent no policies.

Deliberately unchanged + named follow-up: same-mode trusted-proxy reconfiguration still replaces the whole trustedProxy block from the prompted fields, omitting unprompted allowLoopback/deviceAutoApprove — that nested trust-boundary ownership needs a security-owner decision (it interacts with the audit's separate finding that the wizard never surfaces the allowLoopback opt-in at all).

User Impact

Reconfiguring the gateway no longer silently strips brute-force rate limiting or identity scope grants. Mode switches still cleanly remove the abandoned mode's credentials.

Evidence

  • Failing-first: existing rateLimit + identityScopes survive a same-mode pass (pre-fix: deleted); mode-switch matrix (token/password/trusted-proxy × all three, plus fresh config) covered in builder + prompt + gateway wizard tests.
  • Behavior matrix in the worker report covers every transition; the input config is never mutated.
  • check-changed full gates: pass. Codex autoreview: clean.
  • LOC: production +5/−6 (−1); tests +58; docs +1 (configure reference note).

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 1:31 PM ET / 17:31 UTC.

ClawSweeper review

What this changes

This PR preserves existing Gateway rate-limit, identity-scope, and Tailscale policies when interactive configure replaces the selected authentication mode’s credentials or proxy settings.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No introduced correctness defect was found: the PR repairs the current configure-path policy loss at its producing builder. Keep it open for the existing maintainer/security review and exact-head checks.

Priority: P1
Reviewed head: 7285c50d94203311068801b0a69b6412c1c1b8e8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and owner-boundary aligned, with meaningful regression coverage; exact-head checks remain to complete.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; its focused test design was inspected, but not executed in this read-only checkout.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; its focused test design was inspected, but not executed in this read-only checkout.
Evidence reviewed 6 items Introduced repair: The builder now copies existing authentication policy, removes only token, password, and trusted-proxy fields, then applies the selected mode.
Caller and policy contract: The interactive Gateway prompt passes the existing auth block into the builder; the schema defines rateLimit and identityScopes as distinct auth fields.
Runtime consequence: Gateway startup reads gateway.auth.rateLimit, and admission adds scopes only from the configured verified-identity mapping.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw configure --help

Result: PASS (completed)

$ node scripts/run-node.mjs configure --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 99.44 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s

Assertions:

  • PASS expect_output: configure

How this fits together

The configure wizard reads an existing Gateway configuration and rebuilds its authentication block before saving it. Gateway startup then consumes the retained rate-limit policy, while connection admission uses identity scopes for verified identities.

flowchart LR
  A[Existing Gateway config] --> B[Configure wizard]
  B --> C[Auth configuration builder]
  C --> D[Updated auth block]
  D --> E[Gateway startup]
  E --> F[Rate limits and identity scopes]
Loading

Decision needed

Question Recommendation
Should interactive Gateway reconfiguration preserve existing rate-limit and verified-identity scope policy while replacing only the selected authentication mode’s credentials or proxy settings? Confirm retention and land: Keep the policy-preserving builder behavior after exact-head checks pass, because it retains explicit operator controls while removing stale mode credentials.

Why: This changes the persistence behavior of Gateway ingress protections and grants, so a Gateway/security owner should explicitly confirm the retained-policy boundary before merge.

Before merge

  • Resolve merge risk (P1) - The supplied GitHub check rollup was still queued or in progress for this exact head, so merge validation remains incomplete despite the PR-body test claim.
  • Complete next step (P2) - A Gateway/security owner must confirm the retained-policy boundary; exact-head checks also remain incomplete.
Agent review details

Security

None.

PR surface

Source -1, Tests +58, Docs +1. Total +58 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 6 -1
Tests 2 87 29 +58
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 93 35 +58

Review metrics

Metric Value Why it matters
Production versus test delta production +5/-6 (net -1); tests +87/-29; docs +1 The bug fix is production-net-negative while expanding focused builder and wizard coverage.
Gateway auth policy behavior 3 existing policies preserved; 0 configuration options added The change retains allowTailscale, rateLimit, and identityScopes rather than adding or changing the public configuration schema.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the producer-level split between independent auth policies and mode-owned credentials, then land once a Gateway owner accepts that boundary and exact-head checks complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the producer-level split between independent auth policies and mode-owned credentials, then land once a Gateway owner accepts that boundary and exact-head checks complete.

Do we have a high-confidence way to reproduce the issue?

Yes—source inspection shows the pre-PR builder starts with an empty object and therefore drops rateLimit and identityScopes whenever configure calls it with existing auth.

Is this the best way to solve the issue?

Yes—the builder is the canonical producer of the rewritten auth block; copying existing policy and deleting mode-owned fields is narrower and safer than duplicating field preservation in callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fd7e9bbaceb1.

Labels

Label justifications:

  • P1: The repaired configure path can otherwise silently remove active Gateway rate limiting and verified-identity grants.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; its focused test design was inspected, but not executed in this read-only checkout.

Evidence

What I checked:

Likely related people:

  • steipete: Recent configure and Gateway setup commits include the persistence and startup-readiness work adjacent to this command path. (role: recent configure-area contributor; confidence: high; commits: 227230024d06, 2fd16c2855b8; files: src/commands/configure.gateway.ts, src/commands/configure.wizard.ts)
  • Yiğit ERDOĞAN: Git blame identifies this commit as the origin of the prior empty-base implementation in the extracted auth helper. (role: introduced current helper; confidence: high; commits: 73b98c4b5016; files: src/commands/configure.gateway-auth.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head configuration checks finish, then obtain the required Gateway/security-owner review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-27T16:59:15.973Z sha 7285c50d94203311068801b0a69b6412c1c1b8e8 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 27, 2026 17:24
Replace fake auth factories and builder-call assertions with returned-config checks. Cover password policy preservation, generated-token parity, and SecretRef output without changing production behavior.
@steipete
steipete force-pushed the steipete/configure-auth-preserve branch from 7285c50 to 4d7dd31 Compare August 27, 2026 18:10
@steipete
steipete merged commit 80082b2 into main Aug 27, 2026
201 checks passed
@steipete
steipete deleted the steipete/configure-auth-preserve branch August 27, 2026 18:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…guration (openclaw#131035)

* fix(configure): preserve unrelated gateway auth policy across reconfiguration

* test(configure): exercise real auth builder in gateway prompt tests

Replace fake auth factories and builder-call assertions with returned-config checks. Cover password policy preservation, generated-token parity, and SecretRef output without changing production behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant