Skip to content

fix(S-54): load OP_SERVICE_ACCOUNT_TOKEN first in secrets.fish#77

Closed
tieubao wants to merge 1 commit into
mainfrom
fix/secrets-load-sa-first
Closed

fix(S-54): load OP_SERVICE_ACCOUNT_TOKEN first in secrets.fish#77
tieubao wants to merge 1 commit into
mainfrom
fix/secrets-load-sa-first

Conversation

@tieubao
Copy link
Copy Markdown
Member

@tieubao tieubao commented May 7, 2026

Summary

  • Reorders home/dot_config/fish/conf.d/secrets.fish.tmpl so OP_SERVICE_ACCOUNT_TOKEN is loaded before iterating the rest of .secrets. Go's range sorts map keys alphabetically, so without this reorder CLOUDFLARE_API_TOKEN was loading first.
  • Suppresses a 1Password "Allow tailscaled to access 1Password?" popup that appeared on every cold mosh session into tieubao@mini after S-51 widened the gate to is-login and S-53 seeded only the SA token in System.keychain.

Why "tailscaled"?

After S-51 / S-53, on \$SECONDARY hosts the alphabetically-first var (CLOUDFLARE) cache-misses → op read runs with empty \$OP_SERVICE_ACCOUNT_TOKEN → falls back to 1P Desktop integration → 1P walks the peer-PID parent chain looking for a non-shell ancestor. With Tailscale SSH as the SSH transport, that chain is launchd → tailscaled → /usr/bin/login → fish → bash → op. Shells / login get skipped; tailscaled is the first "interesting" ancestor. Hence the misattribution.

After this fix, every op read runs with bearer auth in env → bypasses Desktop integration entirely → no attribution walk → no popup.

Test plan

  • chezmoi execute-template rendered output puts OP_SERVICE_ACCOUNT_TOKEN line first
  • fish -n clean on rendered output
  • Deploy on tieubao@mini, confirm fresh mosh session triggers no popup
  • Confirm \$OP_SERVICE_ACCOUNT_TOKEN, \$CLOUDFLARE_API_TOKEN, \$R2_* all populated in remote shell

Notes

Branched off main, not feat/multi-machine-op (PR #76), to respect scope-lock. Trivial 3-way merge if/when #76 lands first.

Spec: docs/specs/S-54-load-sa-token-first.md.

🤖 Generated with Claude Code

Go's `range` sorts map keys alphabetically, so CLOUDFLARE_API_TOKEN was
loaded before OP_SERVICE_ACCOUNT_TOKEN. On $SECONDARY hosts where the
SA token sits in System.keychain (S-53) but other vars don't, the
CLOUDFLARE cache miss called `op read` with no bearer in env, falling
through to 1P Desktop integration. 1P walked the peer-PID parent chain
to attribute the request and landed on `tailscaled` (the SSH-transport
ancestor when Tailscale SSH is in use), popping an "Allow tailscaled
to access 1Password?" dialog every cold mosh session.

Reordering so OP_SERVICE_ACCOUNT_TOKEN loads first means subsequent
cache misses fall through to bearer-auth `op read` directly against
the 1P API: no Desktop integration, no app-attribution walk, no popup.

Branched off main (PR #76 still open with S-51 scope per scope-lock
rule).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tieubao
Copy link
Copy Markdown
Member Author

tieubao commented May 8, 2026

Closing as superseded: the SA-token-first ordering fix landed via commit 7c4ffc4 (refactor/op-vault-split, 2026-05-08), which preserved this PR's reorder while doing the broader vault-split migration. Verified via git show origin/main:home/dot_config/fish/conf.d/secrets.fish.tmplOP_SERVICE_ACCOUNT_TOKEN is loaded before the range loop with the same rationale comment. Spec doc not separately merged; the rationale is captured in 7c4ffc4's commit message and is also preserved in this PR's body for posterity. Branch fix/secrets-load-sa-first will be deleted.

@tieubao tieubao closed this May 8, 2026
@tieubao tieubao deleted the fix/secrets-load-sa-first branch May 8, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant