Skip to content

fix: isolate GitHub token selection by cwd git remote owner#28

Merged
smartwatermelon merged 1 commit intomainfrom
claude/fix-token-isolation
Mar 27, 2026
Merged

fix: isolate GitHub token selection by cwd git remote owner#28
smartwatermelon merged 1 commit intomainfrom
claude/fix-token-isolation

Conversation

@smartwatermelon
Copy link
Copy Markdown
Owner

Summary

  • load_github_token() now detects the repo owner from the cwd's git remote and selects the matching per-org token (GH_TOKEN_{OWNER} env var → flat file fallback)
  • Moved load_github_token call to after inject_secrets in the wrapper so 1Password env vars are available
  • Removed default GH_TOKEN from secrets.op and deleted the default gh-token flat file to prevent cross-org token leakage

Previously, sessions in nightowlstudiollc repos started with the smartwatermelon token as default, giving access to both orgs. Now the session token matches the cwd's repo owner.

Test plan

  • Start a session in ~/Developer/clients/amelia-boone — verify only nightowlstudiollc repos accessible
  • Start a session in ~/Developer/claude-wrapper — verify only smartwatermelon repos accessible
  • Start a session outside any git repo — verify no GH_TOKEN set (graceful degradation)
  • Verify shellcheck passes on both modified files

🤖 Generated with Claude Code

load_github_token() now detects the repo owner from the cwd's git
remote and selects the matching per-org token (env var or flat file).
This prevents sessions in nightowlstudiollc repos from getting the
smartwatermelon token.

Key changes:
- Detect cwd owner from git remote origin URL
- Check GH_TOKEN_{OWNER} env vars before flat files
- Move load_github_token call after inject_secrets in the wrapper
  so 1Password-injected env vars are available
- Remove default GH_TOKEN from secrets.op to prevent override

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@smartwatermelon smartwatermelon merged commit 09f178d into main Mar 27, 2026
4 checks passed
@smartwatermelon smartwatermelon deleted the claude/fix-token-isolation branch March 27, 2026 17:40
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