Commit graph

8 commits

Author SHA1 Message Date
0738171f1e Archive sessions, allow spaces in names, stop tripping the SSH rate limit
Connection refused: the dev box's UFW `limit` rule refuses the 6th new
SSH connection from one address within 30 s. Every page view made two
calls (list, repos) and every button one more, so stopping two sessions
and refreshing hit it (kernel log: "UFW LIMIT BLOCK" from prod's IP).
The web app now multiplexes all calls over one connection
(ControlMaster=auto, ControlPersist=120), with the socket in its private
temp dir. compose.yaml gets `init: true` so the backgrounded master is
reaped; the app warns if it runs as PID 1.

Spaces in names: `create` now takes a title (letters, digits, '-',
single spaces, <= 48 chars). The slug used for the directory, branch,
unit and tmux socket is derived from it; the title is shown on the page
and passed to claude as --name. A plain slug still maps to itself.

Archive: new remote verbs `archive` (stop + flag, keeps checkout and
conversation) and `unarchive` (back to the list, still stopped). An
archived session refuses `start`. The page lists archived sessions in a
collapsible section. `list` re-reads state under the lock before saving
a Remote Control URL so it can't undo a concurrent archive.

Also: name/branch validation used re.match with `$`, which accepts a
trailing newline; it now uses fullmatch.

Tested end to end with a throwaway 127.0.0.1 key and the real container:
24 remote calls went over 1 TCP connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rog8S9b5qKaw6nUicxXLkM
2026-10-06 09:42:40 +00:00
2569937fa7 Merge pull request 'Start sessions with --dangerously-skip-permissions' (#1) from session/test into main
Reviewed-on: #1
Reviewed-by: reudy <jakubadorfman@proton.me>
2026-09-30 18:16:42 +02:00
ece7458a55 Start sessions with --dangerously-skip-permissions
Unattended sessions otherwise stop at every tool approval until someone
answers through Remote Control. The limits that make this acceptable (bot
token scoped to allowlisted repos, branch protection, nothing production on
the box) are written down in the README's security model, along with the
remaining risk of prompt injection.

The one-time bypass-mode warning would block an unattended session. It's
suppressed by skipDangerousModePermissionPrompt in ~/.claude/settings.json,
and if it ever shows anyway, status now reports it as needs_attention, the
same way as the folder-trust prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CyWXJ3BVzrZ9VWk5c2CoAr
2026-09-30 16:12:46 +00:00
b55ea07c96 Run sessions-web behind Authelia, configured only by env vars
Drop the app's own login (password hash, signed cookies, CSRF tokens, rate
limiting): Authelia via Caddy forward_auth is the login. The app refuses any
request without the Remote-User header (optionally limited to
SESSIONS_ALLOWED_USERS) and any cross-site POST (Sec-Fetch-Site / Origin).

The SSH key and the dev box host key now come from environment variables
printed by `sessions-ctl keygen`, so the container needs no secrets store or
mounts. Add compose.yaml so prod's panel can build and deploy it; remove the
Quadlet unit and the files it needed. README covers the panel deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKYfRST9cTJYae3f7Jf3ac
2026-09-30 14:39:56 +00:00
ca66db3aeb Add sessions-ctl keygen to create prod's key on the dev box
keygen generates an ed25519 pair in RAM, writes the public half to
config.toml and authorized_keys (replacing the previous sessions-manager
line) and prints the web app's environment - dev host, port, user, pinned
host key and the private key as one base64 line - then deletes the private
key, so the pasted copy is the only one. Refuses to replace an existing key
without --rotate. Local only, never reachable over SSH.

Also make load_config() read CONFIG_PATH at call time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKYfRST9cTJYae3f7Jf3ac
2026-09-30 14:39:56 +00:00
08636ddc25 Document setup, security model and conventions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:55:38 +00:00
7a2077f730 Add sessions-web, the prod-side web page and container
Stdlib-only Python app: password login (scrypt), signed SameSite=Strict
cookie, CSRF tokens, login rate limiting, strict CSP and no JavaScript. Every
action is one ssh call to sessions-ctl with a pinned host key. Ships a
Containerfile and a Podman Quadlet unit (rootless, read-only root, all
capabilities dropped, published on 127.0.0.1 only, secrets via podman secret).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:55:38 +00:00
1816f6f863 Add sessions-ctl and systemd units for the dev box
sessions-ctl creates, starts, stops and lists Claude Code sessions. Each one
is a checkout in ~/sessions/<name>, a state file and a systemd user unit that
runs claude with Remote Control in its own tmux server. Sessions are restarted
if they crash, come back at boot (linger), and resume the same conversation
by a pinned session UUID.

Over SSH it runs as a forced command: only list/repos/status/create/start/
stop/health are accepted, arguments are validated, and nothing reaches a shell
or Claude as a prompt. refresh-access keeps the key's from= restriction in
sync with the IP of reudy.net (hourly timer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:55:38 +00:00