feat(init): Ask for the profile name and hide the API key - #31
Merged
Merged
Conversation
`lago init` never asked for a profile name, so an interactive run always wrote `default` and configuring a second environment overwrote the first. The API key was read with the echoing prompt, leaving a secret in the terminal scrollback and in screen shares. init now asks for the profile name first, defaulting to the current profile, and reads the key through term.ReadPassword. Both prompts are skipped when --profile/LAGO_PROFILE or --api-key/LAGO_API_KEY already answer them, so scripted init is unchanged. A name typed at the prompt must be letters, digits, dots, dashes, or underscores, and re-initing an existing profile says so before it writes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mikeh-lago
approved these changes
Sep 17, 2026
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.
What changed
lago init, interactive mode only:term.ReadPassword), so the prompt readsAPI key (hidden):and the secret never reaches the scrollback. When stdin is not a terminal, or the reader already holds buffered input, it falls back to the visible prompt — echo was never suppressible there, so tests, pipes, and CI are unaffected.[A-Za-z0-9][A-Za-z0-9._-]{0,63}and is rejected at exit 2 while it can still be retyped.Both prompts are skipped when
--profile/LAGO_PROFILEor--api-key/LAGO_API_KEYalready answer them, so scriptedinitis byte-for-byte unchanged. Names passed via--profileare not validated, so no existing profile stops working.Why
An API key is a secret, and
initwas the one command that printed one back to the terminal. It was never asked for the profile name either, so an interactive run always wrotedefault: configuring a second environment silently overwrote the first, with no point at which the operator could name it.Verification
Driven through a pty against a stub
/organizationsserver: the key stayed off-screen while every other answer echoed, and it still landed in the profile.make securityneedsgitleaks, which is not installed locally; it runs in CI.make testmake coverage(internal/cli 89.2%, floor 86.0%)make lintmake securitymake generate-check🤖 Generated with Claude Code