diff --git a/PLAN.md b/PLAN.md index 95d0521..368ed5c 100644 --- a/PLAN.md +++ b/PLAN.md @@ -793,5 +793,7 @@ from PowerDNS for `.`. markers first (the installer's location on customer Cores, Superpanel's screen, add-on billing, the groups claim, the Actions workflow). The pages live only in `federated-documentation` - - [ ] `coreapps login` on the Core reads the token with no prompt and - shows it as typed; give it a hidden prompt before owners use it + - Done 2026-12-04: `coreapps login` at a terminal asks for the token + 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" diff --git a/TEST.md b/TEST.md index 79dc344..689a906 100644 --- a/TEST.md +++ b/TEST.md @@ -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 `/root/.docker/config.json` has no entry for the host. `coreapp logout `: installing fails again. +6b. `coreapps login ` run at a terminal on the Core (`ssh + -tt`): it asks "Token for on : " 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 + | coreapps login ...`, as `coreapp login` does): no prompt, the + same checks. `/etc/coreapps/credentials` unchanged after all three. 6a. Tokens per owner: `coreapp login /` with a wrong token is rejected, the file unchanged. With a token saved for `/` (on the Core, a wrong one written with `write_credentials`, to see which diff --git a/core/coreapps b/core/coreapps index f363d61..db2a0b6 100755 --- a/core/coreapps +++ b/core/coreapps @@ -23,7 +23,8 @@ coreapps update [--addon-ok] update an app installed from a coreapps remove uninstall an app installed by coreapps coreapps list the apps installed by coreapps coreapps login [/] - 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 /: 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)