Skip to content

How to add a project (user) post deployment? #352

Description

@lionello

TL;DR — Add a tool and a UI that create a project (= linux user) after deployment. Today this needs a Nix edit plus nixos-rebuild switch. Build it on the native backend (#325), where agentbox apply already does the work. Gate it behind the deployment password, which is the admin credential.

This body is the current state of the discussion. The comments below hold the working detail.

The ask

During deployment we create a linux user with a password for HTTP basic auth. The user is the isolated env. One user can run many agents (see #321) which some customized settings, but for real isolation we'd need a new user.

Suggest to add a tool+UI to create a new user. This could be on the root (see #221) with a new route for scope access to allow adding linux user = project. If so, the root UI needs to change to remove the redirect and to explain user = project (without using too much slang).

Settled

  1. The deployment password is the admin credential. It authenticates the box owner, never a project. So "add project" sits behind it, not behind a project user's basic auth. "Root" in the earlier comments means the root route, not uid 0. The scope is the admin scope: web login admin, its own hash and its own cookie, and admin is a reserved project name. No uid-0 daemon anywhere.
  2. Native-first. No nixos-rebuild round-trip, because Portability: native Ubuntu/RHEL support (Nix-without-NixOS) — refactor tracker #154 Phase 4 removes that path. NixOS boxes get the same button at Phase 5, when the option tree renders the same spec.
  3. The mechanism already exists. cmd_apply in bin/agentbox (refactor(native): Ubuntu/RHEL backend — no nixos-infect (#154 Phase 4) #325) creates the login, renders the per-user env, drop-ins, sudoers and Caddyfile, enables that user's four template instances, and disables the instances of a user that left the config. So "add a project" is one validated users: entry in /etc/agent-box/config.yaml, then agentbox apply. No second spec file.
  4. Privilege, with no uid 0. Whoever can write config.yaml is root-equivalent, because apply renders sudoers.d fragments and unit drop-ins from it. So the admin daemon never writes that file and never runs as root. Instead a narrow wrapper — agent-box-project add|set-password|rm NAME — behind one sudoers line, the same shape as agent-box-session and agent-box-webhook.
  5. / stops being served by a project's settings daemon. Today it proxies to rootUser's daemon with AGENT_BOX_HOME=1 (modules/agent-box.nix.in:2374). That daemon runs as an unprivileged project user, and that project's agent can reach its socket. A separate admin daemon owns /; the per-user daemons keep zero privileged actions.
  6. The single-project box does not change. Admin may enter any project, so a sign-in at / mints the chosen project's cookie and lands in the workspace. No picker. The picker appears with two or more projects. So the redirect stays, but it means "admin opens the only project".
  7. Each project gets its own password, set by admin at creation. A per-project password matters when you hand one project to a different person. Native first_boot currently hashes the same deployment password into every /etc/agent-box/<user>.hash (bin/agentbox:927); that loop must write the admin hash only.
  8. Avoid sending WebPassword plaintext to CloudFormation/user-data #25 matters more now. The deployment password is the highest-value credential on the box, and it travels as plaintext through CloudFormation and user-data. So the admin page must also rotate it.

Blocker

#325 must gain an auth-secrets oneshot first. /run/agent-box-web/env holds WEB_PASSWORD_HASH_* and WEB_COOKIE_SECRET_*. Only apply --first-boot writes it (bin/agentbox:938), and caddy.service requires it with no - prefix (bin/agentbox:285). /run is tmpfs, and cloud-init runs first-boot once. So a native box loses its whole web front door on the first reboot, and a project added later has no hash and no cookie secret in that file. Fix: port webAuthSecretsService to the native renderer as a oneshot, RequiredBy=caddy.service. Reported on #325.

Plan

  1. refactor(native): Ubuntu/RHEL backend — no nixos-infect (#154 Phase 4) #325 merges.
  2. Auth-secrets oneshot in the native renderer.
  3. The agent-box-project wrapper, plus its one sudoers line.
  4. The admin route: its own hash and cookie, the project picker, "add project", and password rotation.
  5. NixOS parity at Portability: native Ubuntu/RHEL support (Nix-without-NixOS) — refactor tracker #154 Phase 5.

Related: #321 (profiles: many agents in one project), #221 (the /user/session path hierarchy), #127 (users are the trust boundary, sessions are the unit of work), #154 / #295 / #325 (the native refactor), #25 (plaintext deployment password), #313 (the other privileged affordance on the same page).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions