Self-hosted
Run aithorized on your own host or in your VPC: the dashboard, the API, Postgres and Redis, behind one Caddy on one domain.
What you get
| Service | Image | Role |
|---|---|---|
caddy | built from deploy/self-hosted/app.Dockerfile | TLS (Let's Encrypt, or its internal CA for private names), the dashboard, and /v1 + /scim forwarded to the backend |
backend | built from packages/backend/Dockerfile | REST, SSE, the phones' WebSocket, SAML and SCIM. Migrates the database at start |
postgres | postgres:16-alpine | Source of truth: requests, signatures, audit chain, policies |
redis | redis:7-alpine | Hot copies, nonces, locks, events across instances; rebuilt from Postgres, never persisted |
Agents, phones and identity providers all use the same origin: https://<your domain>/v1. The containers talk on a private network, AITHORIZED_INTERNAL_SUBNET (default 192.168.237.0/24). Change it if it overlaps your VPC or LAN.
Run it
cd deploy/self-hosted # in a checkout of the aithorized repository
cp .env.example .env # fill in every secret: openssl rand -hex 32
docker compose up -d --buildSignup is closed (new accounts need an invitation or an access code), so make the first code, sign up with it at https://<your domain>/signup#<code>, and make that account a system admin:
docker compose exec backend node --import tsx db/platform-voucher.ts "First admin"
docker compose exec backend node --import tsx db/platform-grant.ts [email protected]Further codes are made in Platform → Signup access codes. Set AITHORIZED_SIGNUP=open to let anyone sign up instead.
Then pair a phone from Devices. Point agents at it with the Connect an agent card, which shows the API URL and the policy key to pin.
Checks after the first start:
docker compose ps: all four services up, the backendhealthy(its image checks/healthinside the network; Caddy does not expose it).curl -i https://<your domain>/v1/web/meanswers401with a JSON error: the API is reachable through Caddy.docker compose logs backendshowsstate: postgres + redisand no migration error.
The policy key
The backend signs every workspace's policy bundle and phone key directory with one Ed25519 key. Agents pin its public half and fail closed without a valid signature. Set it in AITHORIZED_POLICY_KEY_JWK, an Ed25519 private JWK on one line (the command is in .env.example), and keep a copy somewhere safe.
To replace it, rotate: set a new AITHORIZED_POLICY_KEY_ID and key, list the old public half in AITHORIZED_POLICY_PREVIOUS_KEYS, and give agents both public keys (the Connect an agent card lists them). Each policy is re-signed with the new key on first use, recorded as policy.key_rotated in its audit log.
Keeping the key in an HSM is not available yet. It is on the roadmap.
Upgrades and backups
- Upgrade:
git pull && docker compose up -d --build. Migrations are forward-only and run under a lock, so instances never race. - Back up the
pg-datavolume (orpg_dumpasaithorized_owner). Redis holds nothing that is not in Postgres. - Never lose the policy key. Without it no agent can verify a new policy.