Ask for the token without showing it in coreapps login

At a terminal, coreapps login on the Core now prompts with getpass;
piped (as coreapp login does), it still reads one line from stdin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 09:10:38 -07:00
co-authored by Claude Opus 5.5
parent a8d94b6711
commit 58f90de66f
3 changed files with 23 additions and 4 deletions
+13 -2
View File
@@ -23,7 +23,8 @@ coreapps update [--addon-ok] <name> update an app installed from a
coreapps remove <name> uninstall an app installed by coreapps
coreapps list the apps installed by coreapps
coreapps login <host>[/<owner>] <user>
keep a token (read from stdin) for
keep a token (asked for, not shown;
or one line on stdin) for
installing private apps from host
(with /<owner>: that owner's apps only,
used before the host's token)
@@ -54,6 +55,7 @@ tier would record the app as a billable add-on and --addon-ok isn't given.
import base64
import email.parser
import email.policy
import getpass
import glob
import html.parser
import json
@@ -445,7 +447,16 @@ def login(arg, user):
host = key.split("/", 1)[0]
if not re.fullmatch(LOGIN_USER, user):
raise Refused(f"'{user}' isn't a user name.")
token = sys.stdin.readline().strip()
if sys.stdin.isatty():
# Typed or pasted by a person: asked for, and not shown
try:
token = getpass.getpass(f"Token for {user} on {key}: ").strip()
except (EOFError, KeyboardInterrupt):
sys.stderr.write("\n")
raise Refused("No token given. Nothing was saved.")
else:
# Piped in (coreapp login on the workstation): one line
token = sys.stdin.readline().strip()
if not re.fullmatch(TOKEN, token):
raise Refused("That isn't a token (8-512 letters, digits and . _ ~ + / = -).")
ok = check_token(host, user, token)