Quickstart

Connect a Postgres database, run a command with a temporary key, take the key back, and read the audit log.

Keys are leases in the CLI

The docs say key and rule. The ward CLI says lease and template, so you'll type --lease and pick a template.

Sign in

Approve the code ward shows in the console. Your session is saved in ~/.ward/token, a file only you can read.

ward login --web

Connect Postgres

A connector runs in your network and holds the admin login for one database. Give it a role that can create roles but isn't a superuser:

CREATE ROLE ward_parent LOGIN CREATEROLE PASSWORD '...';
GRANT SELECT ON TABLE public.orders TO ward_parent WITH GRANT OPTION;

Then get a setup token for the connector. Each token works once, within the hour, so a connector with replicas gets one per replica:

ward connector enrol shop-db
ward connector enrol shop-db --replicas 2

Deploy the connector with that token and the role's connection string.

Run a command with a temporary key

Put ward run in front of the command. Your connector makes a new Postgres login, ward puts it in DATABASE_URL for that command only, and revokes it when the command exits.

ward run --lease DATABASE_URL=orders-read -- npm start

Nothing is written to .env. In Postgres, pg_stat_activity shows the connection under its own role name, starting ward_.

Revoke in an incident

Find the key and revoke it. A key your connector made ends when the connector next checks in, every 15 seconds by default. On Postgres, MySQL and Redis that also closes the connections already open.

ward leases
ward revoke 8fde951c

To stop an agent and every key it holds:

ward agent ls
ward agent end 5c1e9a0b

Read the audit log

Every request, refusal and revocation is in the audit log. Entries can be added, never changed.

ward audit --since 1h
ward audit --since 1d --csv > audit.csv