feat: non-interactive login (--password-stdin, --mfa-command) - #7
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds opt-in flags so
auth loginworks 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 getsZELT_MFA_METHOD/ZELT_MFA_SINCEso it can skip a stale codeAlso fixes two latent
SetPasswordkeychain bugs that bit on every re-login (not just automated use):security ... -wreading from stdin prompts for the value twice (enter + retype); we sent it once, storing a wrong/truncated value.-Uis silently ignored for stdin-fed values, so it erroredalready existsonce an entry was present. Now delete-then-add, idempotent, still keeps the password out ofps.Tests: mfa-command extraction/env/failure paths, and a real-
securitykeychain roundtrip (set/get/set-again/get) guarded to macOS.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ruvnu5ui6v2jxCM1dNcKdT