Installing
latchkey version prints the version, commit and build date.
Signing in
The CLI sends a bearer token from your identity provider, the same token the admin UI uses.latchkey auth login checks it against the server before it
keeps anything, then selects a context for that server.
$XDG_CONFIG_HOME/latchkey/contexts.yaml, ~/.config/latchkey without
it, and tokens live beside them in credentials.yaml, readable by you alone.
LATCHKEY_TOKEN is sent instead of the stored token when set, for CI and
scripts. LATCHKEY_LAYOUT=plain or --layout plain draws tables without
rules. Locally, just token operator prints an operator’s token from the
issuer just infra starts.
Administering a tenant
The admin commands act on the context’s tenant and need its Admin. A member isuser:<id> or service:<id>, and a binding’s member can also be
group:<name>. A binding covers the whole tenant, or one resource when it
names a kind and an id. Removing a binding names it the way adding did.
--force
skips the question. Lists take --limit and print the command for the next
page. roles update changes only what it is given, and --allow replaces
every permission the role has. It is refused if someone else changed the role
in the same moment, and running it again applies it to the role as it is now.
Explain and audit
latchkey explain is the command line form of ExplainAccess. It lists the
bindings that reach the subject, directly or through a group, and flags a
subject id that matched nothing. With a kind and an action it also gives the
decision for that one check. latchkey audit reads the context’s tenant’s
log, newest first, and --instance reads the instance’s log instead, for
operators.
Registering kinds
latchkey register -f pushes a domain’s kinds the way the product does when
it starts, and only the domain’s owner may run it. The manifest is a
RegisterDomainRequest in protobuf JSON, which the SDK’s reg.Manifest()
returns.
A push lists what the server says it changed. Each kind, and the domain
itself, has one row behind + for new, ~ for changed or - for retired.
With --dry-run the server checks the push as it would a real one and keeps
nothing, and the rows are what the push would change. The command fails when
the server would refuse the push, so a CI step catches that before the build
ships. It succeeds whether or not the push would change anything. A push
older than the newest version the server has seen is ignored, so its kinds
are not checked.
Operator commands
latchkey tenants ensure creates a tenant and binds its first Admin. For a
tenant that exists, --admin is bound only when the tenant has no Admin,
such as after the directory deactivated its last one, and only when an
operator runs it. A tenant that has an Admin is left alone.
latchkey audit prune works on the database directly, so it takes no
context and needs no login. --older-than is a duration back from now, such
as 9600h for 400 days, or an RFC 3339 time. It asks first, and a scheduled
job passes --force.
On Postgres it connects as latchkey_owner, with the password in
PGPASSWORD. The log is kept by month in UTC, so it drops the months that
ended before the month the cutoff is in, and an entry can outlive the cutoff
by up to a month. A drop waits for anything reading the log, so the command
gives up after five seconds rather than hold audit writes behind it, and can
be run again. SQLite has no roles, so there it needs write access to
latchkey.db and deletes every entry older than the cutoff. Stop the product
first. One process owns the file, and a management write the product makes
at the same moment can fail and need trying again.
latchkey export moves an embedded install into a service, as described in
Deployment.
Migrations are not a CLI command. The server applies them with -migrate,
as described in Deployment.