Repository navigation
Make site login prompt on the terminal by default - #24
Merged
Merged
Conversation
`ptctl site login SITE` now asks for the username, then the password and the optional two-step code with echo off, and saves the new session cookie to an owner-only file under the user config directory (<config dir>/ptctl/sessions/SITE.cookie), printing its path and a follow-up command. Echo is turned off before each hidden prompt is shown, so nothing typed after the prompt appears is echoed, and Ctrl+C restores echo before exiting 130. Echo control uses golang.org/x/sys directly (termios on Unix, console mode on Windows); no new module is added. Scripts and agents keep --credential-bundle-stdin and gain --cookie-file and --output json (kind site.login, which never contains the cookie). The cookie file is created as an owner-only temporary file before the login request, so an unwritable destination never costs a login attempt, and is renamed into place only after the verifying read. `pt help login` and `site login --help` document every flag, the exit statuses, and the stop reasons. Verified on TJUPT from a pseudo-terminal: one login with a two-step code from a password manager, neither hidden answer in the terminal output, a 0700 directory and 0600 cookie file, and `site status` accepting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
ptctl site login SITEis now interactive by default: it prompts for the username, then the password and optional two-step code with echo off, and saves the new session cookie to an owner-only file. The flags scripts and agents need are documented inpt help login/site login --helpinstead of being required on every run.Deliberate behavior changes
--credential-bundle-stdin,site loginprompts on the terminal. This is the one command that accepts a TTY for secrets; with the bundle, a terminal on stdin is still refused. A non-terminal stdin without the bundle is a usage error (exit 2) pointing at--credential-bundle-stdin. This replaces the former "bundle required" usage error.<user config dir>/ptctl/sessions/SITE.cookie(directory 0700, file 0600, atomic replace). No command reads it back automatically.help configand the safety defaults now mention this exception.--cookie-file PATHsaves the cookie to an explicit owner-only file in both modes.--output table|jsonadds a new JSON kind,site.login, withsite_id,username,session_days,session_expires_at,cookie_fileandrequests_attempted. It never contains the cookie.--output jsonwith the bundle requires--cookie-file, because stdout otherwise carries the cookie.--credential-bundle-stdinwithout--cookie-filestill writes only the cookie line to a pipe or owner-only stdout. Its two refusal messages now end with, or use --cookie-file.site login --helpprints the full help and exits 0.pt help login(orpt help site login) is a new topic, and the unknown-topic list includeslogin.Echo handling
Echo is turned off before each hidden prompt is printed, the same way sudo does it, so nothing typed after the prompt appears is echoed. An early prototype printed the prompt first and then disabled echo, and a pty test that answered immediately saw the password echoed.
golang.org/x/sysdirectly: termios on Unix (TIOCGETA/TIOCSETA on BSD/darwin, TCGETS/TCSETS elsewhere) and console mode on Windows. No new module is added.--credential-bundle-stdin.Verification
gofmt,go vet ./...(also withGOOS=windowsandGOOS=linux),go test -race ./...andgo build -trimpath ./cmd/ptctlpass. The terminal files were also compiled alone for freebsd, openbsd, netbsd, dragonfly, solaris, illumos, aix, android, plan9, js and wasip1.requests=2;site status --cookie-stdin tjupt < filereportedauthenticatedfor the same account.🤖 Generated with Claude Code