Skip to content

Stop encouraging API key on argv for auth login#3

Merged
arcaputo3 merged 1 commit intomainfrom
auth-login-no-argv-key
May 1, 2026
Merged

Stop encouraging API key on argv for auth login#3
arcaputo3 merged 1 commit intomainfrom
auth-login-no-argv-key

Conversation

@arcaputo3
Copy link
Copy Markdown
Contributor

Summary

Chris flagged that quartr auth login --api-key \"\$QUARTR_API_KEY\" leaks the key via shell history, ps, terminal scrollback, and CI logs — anywhere argv is visible. This is especially bad for auth login because that's the exact moment we're committing the key to disk, so any leakage there compounds.

Changes

  • Drop the duplicate subcommand-local --api-key flag from auth login. It was always redundant with the global --api-key (the global gets stripped in extractGlobalFlags before subcommands see it), so removing it has no behavioral impact for any reasonable invocation.
  • Add --api-key-stdin to auth login: reads one trimmed line from stdin. Standard pattern (gh auth login --with-token, kubectl --token, op signin) for piping a secret in from a secret store.
  • Makefile: install target now pipes via stdin instead of argv (printf '%s' \"\$QUARTR_API_KEY\" | quartr auth login --api-key-stdin).
  • README + SKILL.md: recommend export QUARTR_API_KEY=...; quartr auth login (uses env via the standard config precedence) or ... | quartr auth login --api-key-stdin for piped input.

The global --api-key VALUE flag is preserved for one-off commands where the user knowingly accepts the argv leak (CI scripts, throwaway containers, ad-hoc queries) — removing it would be needlessly disruptive.

What I considered and rejected

Chris's specific suggestion ("--api-key should refer to a variable name to look up") would diverge from kubectl/gh/aws/docker semantics where --api-key/--token is always the literal value. Reusing one flag for two semantics would surprise people more than it helps. The fix above gets the security win without the UX divergence.

Test plan

  • pre-commit run --all-files clean
  • go test ./... clean
  • Manual smoke test of all three paths:
    • echo \$KEY | quartr auth login --api-key-stdin writes the piped value
    • QUARTR_API_KEY=... quartr auth login writes the env value
    • quartr --api-key X auth login writes X (global flag still works)
  • make install end-to-end with QUARTR_API_KEY exported persists correctly via the stdin path
  • CI green on this PR

🤖 Generated with Claude Code

Chris flagged that 'quartr auth login --api-key "$KEY"' leaks the key
via shell history, ps, scrollback, and CI logs — anywhere argv is
visible. This is especially bad for auth login, which is the exact
moment we're committing the key to disk.

Changes:

- Drop the duplicate subcommand-local --api-key flag from auth login.
  It was always redundant with the global --api-key (which is stripped
  in extractGlobalFlags before subcommands ever see it), so removing it
  causes no behavior change for any reasonable invocation.
- Add --api-key-stdin to auth login: reads one trimmed line from stdin.
  Standard pattern (gh, kubectl, op) for piping from a secret store.
- Update Makefile install target to pipe via stdin instead of argv.
- Update README and SKILL.md to recommend
  'export QUARTR_API_KEY=...; quartr auth login' (uses env via the
  standard config precedence) or
  '... | quartr auth login --api-key-stdin' for piped input.

The global --api-key flag is preserved for one-off commands where the
trade-off is knowingly accepted (CI scripts, throwaway containers).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arcaputo3 arcaputo3 merged commit 7d8d54e into main May 1, 2026
1 check passed
@arcaputo3 arcaputo3 deleted the auth-login-no-argv-key branch May 1, 2026 19:35
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