#22818: fix(gateway): allow loopback shared-auth fallback when device token drifts
gateway
size: XS
Prompt Request: Loopback token-drift resilience in gateway auth/pairing
Use this prompt to implement and validate the change.
You are working in OpenClaw.
Goal:
Prevent local loopback Control UI lockouts when shared gateway auth is valid but device-token/pairing state has drifted.
Context:
In some local macOS runs, loopback clients can present valid shared auth (token/password) while device-token/pairing state is stale. Current behavior can fail the connection as unauthorized/pairing-required even though local shared auth is valid.
Requirements:
1) Add/ensure loopback shared-auth fallback before device-token hard failure:
- If shared auth is valid and request is loopback/local, treat auth as satisfied.
- Keep existing non-loopback behavior unchanged.
2) Pairing gate behavior:
- For loopback + valid shared auth, bypass hard pairing failure path caused by pairing-state drift.
- Preserve normal pairing requirements for non-loopback clients.
3) Scope constraints:
- Keep change minimal and localized.
- No unrelated refactors.
- No workflow/config schema changes.
Acceptance criteria:
- Reproduced local token-drift scenario no longer locks out loopback client with valid shared auth.
- Non-loopback auth/pairing behavior remains unchanged.
- Diff is reviewable and tightly scoped.
Implementation in this PR:
- File: `src/gateway/server/ws-connection/message-handler.ts`
- Diff size: single-file, small (`+15/-1`)
- Intent: local resilience only, without weakening remote requirements.
Most Similar PRs
#16310: fix(ws-connection): skip device pairing when client authenticates w...
by nawinsharma · 2026-02-14
75.3%
#23503: fix: preserve pairing state on device token mismatch + migrate lega...
by dorukardahan · 2026-02-22
72.9%
#22712: fix(gateway): auto-approve all device pairing for localhost connect...
by NewdlDewdl · 2026-02-21
71.7%
#17425: fix(gateway): auto-approve scope/role upgrades for already-paired d...
by sauerdaniel · 2026-02-15
70.9%
#17379: fix: restore device token priority in device-auth mode
by Limitless2023 · 2026-02-15
70.9%
#21148: fix(gateway): add request-aware pairing recovery hints and docs
by cluster2600 · 2026-02-19
70.9%
#15722: fix: prefer explicit token over stored device token for remote gate...
by 0xPotatoofdoom · 2026-02-13
70.2%
#21651: fix(gateway): token fallback + operator.admin scope superset in pai...
by lan17 · 2026-02-20
69.9%
#22381: Security/Gateway: block cross-origin silent auto-pairing in auth mo...
by bmendonca3 · 2026-02-21
69.9%
#2530: fix(gateway): improve auth error for native apps
by Episkey-G · 2026-01-27
69.4%