feat(login)!: replace --paste/--stdin/--no-browser with --api-key - #7
Merged
Conversation
Loopback OAuth needs a browser on the same machine as the CLI, so `kenari login` could not complete over SSH, on a VPS, or in a container. The loopback flow is unchanged and stays the default. The three headless side paths collapse into one flag. `kenari login --api-key` prompts hidden on a terminal and reads stdin when piped, so an SSH session and a container entrypoint run the same command. Passing the key as a value is rejected: a key on the command line is written to shell history and is readable from /proc/<pid>/cmdline by any user on the machine. Also fixes askHidden, which had no caller before this change. Ctrl-D at the prompt left its promise pending, so the process exited 0 with no credential stored and no error, and `kenari login --api-key && kenari configure` would have run configure against no login. BREAKING CHANGE: --no-browser, --paste and --stdin are removed. Use --api-key instead. Each prints an error naming the replacement.
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.
Problem
kenari logincompletes approval over a loopback callback on127.0.0.1, which needs a browser on the same machine as the CLI. Over SSH or in a container there is no browser, and opening the printed URL on a laptop sends the callback to the laptop's own localhost. The CLI waits out its five minute timeout with no useful error.--pasteand--stdinalready worked headless but were listed only in the usage line, never in the README.Change
Loopback OAuth is untouched and stays the default. The three headless side paths collapse into one flag.
--api-keybranches onprocess.stdin.isTTY, so an SSH session and a container entrypoint run the same command:--no-browser,--pasteand--stdinnow error with a message naming--api-keyand the keys URL, so an upgrade does not strand anyone mid-session.Two guards
The key is rejected as an argv value.
parseFlagswould have swallowed--api-key kn-...happily. A key on the command line goes into shell history on the box and is readable from/proc/<pid>/cmdlineby any user on the machine while the command runs. The error names the pipe form instead.askHiddenwas broken and had no caller. This change is its first. Ctrl-D at the prompt left its promise pending, so the process exited 0 with nothing stored and no error, meaningkenari login --api-key && kenari configurewould have run configure against no login. It now resolves empty oncloseand the caller exits 1.Verification
93/93 pass. Every guard was reverted individually and watched go red before restoring:
askHiddenclose handlerReal binary smoke-tested across the flag matrix, plus two
expectpty runs confirming the hidden prompt stores the key without echoing it, and that Ctrl-D exits 1.credentials.jsonstays0600andlogoutremoves it.Docs
README gains a "Signing in" section: the server/SSH flow, the CI pipe,
KENARI_HOMEfor containers with a read-only home, and why an argv key is refused.