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
+4 -2
View File
@@ -793,5 +793,7 @@ from PowerDNS for `<app>.<domain>`.
markers first (the installer's location on customer Cores, markers first (the installer's location on customer Cores,
Superpanel's screen, add-on billing, the groups claim, the Actions Superpanel's screen, add-on billing, the groups claim, the Actions
workflow). The pages live only in `federated-documentation` workflow). The pages live only in `federated-documentation`
- [ ] `coreapps login` on the Core reads the token with no prompt and - Done 2026-12-04: `coreapps login` at a terminal asks for the token
shows it as typed; give it a hidden prompt before owners use it without showing it (getpass); piped, it reads one line as before.
Tested on dev.fedcom.net. The docs' review marker about it (Private
Coreapps) can go, and its text becomes "paste the token when asked"
+6
View File
@@ -582,6 +582,12 @@ has a `coreapp.toml` with a published, public `image` (e.g. after
token shown); on the Core `/etc/coreapps` is 700, `credentials` 600, and token shown); on the Core `/etc/coreapps` is 700, `credentials` 600, and
`/root/.docker/config.json` has no entry for the host. `coreapp logout `/root/.docker/config.json` has no entry for the host. `coreapp logout
<host>`: installing fails again. <host>`: installing fails again.
6b. `coreapps login <host> <user>` run at a terminal on the Core (`ssh
-tt`): it asks "Token for <user> on <host>: " and what's typed isn't
shown; a wrong token is rejected, nothing saved. Ctrl-D at the prompt:
"No token given. Nothing was saved." on its own line. Piped (`echo
<token> | coreapps login ...`, as `coreapp login` does): no prompt, the
same checks. `/etc/coreapps/credentials` unchanged after all three.
6a. Tokens per owner: `coreapp login <host>/<owner>` with a wrong token is 6a. Tokens per owner: `coreapp login <host>/<owner>` with a wrong token is
rejected, the file unchanged. With a token saved for `<host>/<owner>` rejected, the file unchanged. With a token saved for `<host>/<owner>`
(on the Core, a wrong one written with `write_credentials`, to see which (on the Core, a wrong one written with `write_credentials`, to see which
+12 -1
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 remove <name> uninstall an app installed by coreapps
coreapps list the apps installed by coreapps coreapps list the apps installed by coreapps
coreapps login <host>[/<owner>] <user> 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 installing private apps from host
(with /<owner>: that owner's apps only, (with /<owner>: that owner's apps only,
used before the host's token) 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 base64
import email.parser import email.parser
import email.policy import email.policy
import getpass
import glob import glob
import html.parser import html.parser
import json import json
@@ -445,6 +447,15 @@ def login(arg, user):
host = key.split("/", 1)[0] host = key.split("/", 1)[0]
if not re.fullmatch(LOGIN_USER, user): if not re.fullmatch(LOGIN_USER, user):
raise Refused(f"'{user}' isn't a user name.") raise Refused(f"'{user}' isn't a user name.")
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() token = sys.stdin.readline().strip()
if not re.fullmatch(TOKEN, token): if not re.fullmatch(TOKEN, token):
raise Refused("That isn't a token (8-512 letters, digits and . _ ~ + / = -).") raise Refused("That isn't a token (8-512 letters, digits and . _ ~ + / = -).")