aws-sso: explicit local/remote mode (default local) and ntfy push for approvals
The mode cannot be inferred: Linux/Windows hosts can have a browser and an always-on Mac can serve headless. /aws-sso local|remote, PI_AWS_SSO_MODE in .env; a command-set mode wins; old mac/device names map. PI_AWS_SSO_NTFY pushes the device link (tap to approve), a heads-up when a local login waits >60 s, failures, and 'renewed'. Topic shown only as host + fingerprint. Unprompted logins back off 30 min doubling to 4 h; a run that stopped on an expired session resumes after any later successful login.
This commit is contained in:
@@ -366,13 +366,28 @@ while it is signed in). Off until you enable it.
|
||||
| Command | Effect |
|
||||
|---|---|
|
||||
| `/aws-sso on` / `off` | Enable/disable (persisted in `~/.pi/agent/aws-sso/state.json`) |
|
||||
| `/aws-sso status` | Mode, profile chain, session state, last check, last login |
|
||||
| `/aws-sso status` | Mode, push target, profile chain, session state, last check, last login |
|
||||
| `/aws-sso now` | Log in now |
|
||||
| `/aws-sso mode mac` | Run `aws sso login` on the Docker host over SSH (`~/.ssh-local/config`, host alias `host` or `$PI_AWS_SSO_SSH_HOST`): your own browser opens. Default when the sidecar config exists. |
|
||||
| `/aws-sso mode device` | Run `aws sso login --use-device-code --no-browser` here and show link + code in pi; approve on any device. For SSH/tmux sessions. |
|
||||
| `/aws-sso continue on\|off` | After a request failed on an expired session and the renewal succeeded, send `continue` (default on) |
|
||||
| `/aws-sso local` | **Default.** The machine running Docker has your browser: run `aws sso login` there over SSH (`~/.ssh-local/config`, host alias `host` or `$PI_AWS_SSO_SSH_HOST`). Silent while that browser is signed in. |
|
||||
| `/aws-sso remote` | No browser you can see there (headless server, ssh + tmux, an always-on Mac used as a server): run `aws sso login --use-device-code --no-browser` in the container, show link + code in pi and push them; approve on any device. AWS always asks for a click in this flow. |
|
||||
| `/aws-sso continue on\|off` | After a request failed on an expired session, send `continue` once the renewal succeeds (default on) |
|
||||
| `/aws-sso push-test` | Send a test push |
|
||||
|
||||
`PI_AWS_SSO_REFRESH=1` / `=0` force it on / off regardless of the saved state.
|
||||
Settings in pi-devbox `.env` (reaches the container via `env_file`; recreate the container after editing):
|
||||
|
||||
| Variable | Meaning |
|
||||
|---|---|
|
||||
| `PI_AWS_SSO_REFRESH=1` / `0` | Force the keeper on / off regardless of `/aws-sso on\|off` |
|
||||
| `PI_AWS_SSO_MODE=local\|remote` | Mode when none was set by command (a command-set mode wins) |
|
||||
| `PI_AWS_SSO_NTFY=https://ntfy.sh/<topic>` | Push target: an [ntfy](https://ntfy.sh) topic your phone's ntfy app subscribes to. Treat the topic name as a password (long and random), or use a self-hosted ntfy. |
|
||||
| `PI_AWS_SSO_NTFY_TOKEN` | Access token for a protected ntfy topic (optional) |
|
||||
| `PI_AWS_SSO_SSH_HOST` | SSH alias of the Docker host for `local` (default `host`) |
|
||||
| `PI_AWS_SSO_LOCAL_CMD` | Command run on the host for `local`; `{session}` is replaced by the sso-session name. Default: `exec "${SHELL:-/bin/sh}" -lc 'aws sso login --sso-session {session}'`. Verified on a macOS host; a Linux or Windows host may need its own command so the login can reach the desktop browser from an SSH session. |
|
||||
|
||||
**Pushes** (only when `PI_AWS_SSO_NTFY` is set): the approval link and code (`remote`,
|
||||
tap to open); "login waiting" when a `local` login has not finished after 60 s; a
|
||||
login that did not complete; and "renewed" after a login you were pushed about.
|
||||
Status and logs show only the ntfy server and a fingerprint of the topic.
|
||||
|
||||
**How it detects the end.** Per AWS ("Understanding authentication sessions"), the
|
||||
CLI's 1-hour token is refreshed "as long as the underlying user interactive session
|
||||
@@ -391,11 +406,13 @@ fingerprints (`~/.pi/agent/aws-sso/events.jsonl`); the token the SDK returns is
|
||||
dropped unread.
|
||||
|
||||
**Triggers:** a 20 s timer that checks every 60 s inside the refresh window (every
|
||||
10 min once the token has run out). Unprompted logins happen at most once per
|
||||
30 min, so a login waiting for you does not pile up tabs. `before_agent_start`
|
||||
10 min once the token has run out). Unprompted logins back off (30 min, doubling
|
||||
per unanswered login, at most 4 h), so one waiting for you does not pile up tabs or
|
||||
pushes overnight. `before_agent_start`
|
||||
checks first if the token is in its window and logs in (and waits) if the session
|
||||
is over. `message_end` is the fallback: if a request still fails on an expired
|
||||
token, the keeper renews and sends `continue` (once per 10 min).
|
||||
token, the keeper renews and sends `continue` (once per 10 min), also when you
|
||||
approve hours later.
|
||||
Only interactive sessions act; print/JSON children (`task`, `fork`) stay inert.
|
||||
A lock file stops several pi processes from starting several logins.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user