Skip to content

feat: non-interactive login (--password-stdin, --mfa-command) - #7

Merged
brtkwr merged 2 commits into
mainfrom
noninteractive-login
Aug 21, 2026
Merged

feat: non-interactive login (--password-stdin, --mfa-command)#7
brtkwr merged 2 commits into
mainfrom
noninteractive-login

Conversation

@brtkwr

@brtkwr brtkwr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Adds opt-in flags so auth login works headless; default interactive behaviour is unchanged.

  • --password-stdin - read password from stdin instead of a TTY prompt
  • --mfa-command - run a shell command whose stdout yields the emailed MFA code; runs after the code is sent, and gets ZELT_MFA_METHOD / ZELT_MFA_SINCE so it can skip a stale code

Also fixes two latent SetPassword keychain bugs that bit on every re-login (not just automated use):

  • security ... -w reading from stdin prompts for the value twice (enter + retype); we sent it once, storing a wrong/truncated value.
  • -U is silently ignored for stdin-fed values, so it errored already exists once an entry was present. Now delete-then-add, idempotent, still keeps the password out of ps.

Tests: mfa-command extraction/env/failure paths, and a real-security keychain roundtrip (set/get/set-again/get) guarded to macOS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ruvnu5ui6v2jxCM1dNcKdT

brtkwr and others added 2 commits August 21, 2026 15:53
auth login gains two opt-in flags for headless/scripted use; the default
interactive prompts are unchanged. --password-stdin reads the password from
stdin; --mfa-command runs a shell command whose stdout yields the emailed MFA
code (exported ZELT_MFA_METHOD / ZELT_MFA_SINCE so it can ignore stale codes).

Also fixes two real keychain bugs SetPassword hit on every re-login:
- security add-generic-password -w reads from a prompt that asks for the value
  twice (enter + retype); we were sending it once, storing a wrong value.
- -U (update) is ignored for stdin-fed values, so it errored "already exists"
  once an entry existed. Switched to delete-then-add, which is idempotent and
  keeps the password out of argv.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ruvnu5ui6v2jxCM1dNcKdT
The command runs via sh -c (dash on Linux CI); the previous ${VAR: -2}
substring expansion is a bashism that failed there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ruvnu5ui6v2jxCM1dNcKdT
@brtkwr
brtkwr merged commit 399e592 into main Aug 21, 2026
1 check passed
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