Administration
The administration API for databases, users, grants, keys and deployment roles, the operator commands of mimicd admin, and lost superuser credentials.
A deployment is administered through two interfaces:
- The administration API,
/v1/adminon the public listener, with a user's password or a key: databases, users, grants, keys, limits, collections, backups, and the deployment's status. mimicd admin, the operator commands, which connect to PostgreSQL with the store's credentials: settings, stores and moves, backups and restores, quarantine, the usage history, the audit trail, and a lost superuser's reset.
How the tools authenticate
The administration API takes a user's name and password (HTTP Basic) or a
key (Authorization: Bearer mk_…), and decides each call by the caller's
permission, as every request is decided. A route declares who may ask it:
a superuser; the user it names (a password change); a permission on the
database it names; or a deployment permission, which superusers hold and
deployment roles give.
Every mimicd admin command connects to the home store, from
MIMIC_POSTGRES_URL (or --postgres-url, which refuses a URL holding a
password), and those that read partitions to every other store
(--store NAME=URL, or MIMIC_STORE):
export MIMIC_POSTGRES_URL='postgres://mimicd@db.example:5432/mimic?sslmode=verify-full'
export PGPASSFILE=~/.pgpass
mimicd admin statusThere are no operator certificates: whoever holds the store's credentials
can run every command (see Security).
A command that changes something is audited as operator:<name>, from
MIMIC_OPERATOR_NAME or the system's user name. A command opens only a
deployment's founded home of its own build's schema (exit code 5
otherwise) and never migrates a store.
Founding a deployment
The first mimicd serve on a store founds the deployment and creates the
bootstrap superuser (--bootstrap-admin, with its password from
--bootstrap-password-file or MIMIC_BOOTSTRAP_PASSWORD).
mimicd serve --init-only does the same and exits. See
PostgreSQL stores.
The operator commands
| Command | Does |
|---|---|
settings get, list, set NAME=VALUE … | The deployment settings |
status | The deployment's status, read from its stores |
stores list, add, reconcile, recount | The stores |
partition move, database move, store drain, moves show, cancel | Moves between stores |
operations list, show | The long-running operations |
database purge DB, placement DB | A database's removal, and which store holds each partition |
database fence, unfence | A fence of a database's home, to move it to another deployment |
backup list, show, start, verify, expire, status, cancel, restore | Backups and restores |
access export, import | A database's users, grants and keys, carried between deployments |
quarantine list, release, doc-ref | Quarantined documents |
usage feed, history, audit read | The usage history and audit trail |
pki clear-domain, clear-account | ACME's records (see Network and TLS) |
superuser reset NAME | A lost superuser |
mimicd --help lists them with their arguments. settings, quarantine,
superuser and pki take --json; status, usage, audit,
operations, the stores' and moves' commands, backup, restore and
database always print JSON. Limits, keys, users and endpoints are not commands:
the administration API serves them.
The administration API
The paths below are under /v1/admin and take and answer JSON. Lists never
hold a password hash or a key's digest.
Databases
A database is created under an id its caller draws, 32 lowercase hexadecimal digits, with its budget group and its number of partitions, fixed for its life, and optionally the store it goes to:
curl -u admin:"$PASSWORD" -X PUT -H 'Content-Type: application/json' \
-d '{"budget_group": "default", "partitions": 4}' \
"https://mimic.example.com/v1/admin/databases/$DB"| Request | Who | Does |
|---|---|---|
PUT /databases/{db} | superusers | Creates it: { budget_group, partitions, store? }. The same again is done |
GET /databases/{db} | databases.list | { id, budget_group, partitions, ready }, and access_mode when not read_write |
GET /databases?after=&limit= | databases.list | Databases, a page at a time (limit 1 to 1,000) |
DELETE /databases/{db} | superusers | Removes it and all its documents; its id is never used again |
GET /databases/{db}/purge | databases.list | Its removal read back: whether every store has dropped its rows |
GET /databases/{db}/placement | stores.read | Each partition's store |
GET, PUT /databases/{db}/access-mode | databases.read, superusers | { mode }: read_write, read_only or blocked |
A database has no name in the server: whatever names it elsewhere maps to its id. A removed database's rows are purged in the background; its backups are not, and expire by age.
A read_only database refuses every document write and every mint of a
write token, for anyone but a superuser, while its sessions stay open; a
blocked one refuses everything. Its data, keys and grants stay, so a
database can be suspended and resumed without removing it.
Users and grants
| Request | Who | Does |
|---|---|---|
POST /users | superusers | { name, password, superuser?, roles? } |
GET /users | superusers | Lists users, with their roles |
PUT /users/{name}/password | superusers, the user itself | { password } |
PUT /users/{name}/superuser | superusers | { superuser } |
PUT /users/{name}/disabled | superusers | { disabled } |
DELETE /users/{name} | superusers | Removes the user and its grants |
GET /databases/{db}/grants | the database's admins, superusers | [{ user, permission }] |
PUT /databases/{db}/grants/{user} | the database's admins, superusers | { permission }: read, write or admin |
DELETE /databases/{db}/grants/{user} | the database's admins, superusers | Removes the grant |
The last enabled superuser cannot be disabled, demoted or removed.
Database keys and token keys
| Request | Who | Does |
|---|---|---|
POST /databases/{db}/keys | the database's admins, superusers | { name, permission }, answered { id, key } once |
GET /databases/{db}/keys | the database's admins, superusers | The database's keys |
POST /databases/{db}/keys/{id}/revoke | the database's admins, superusers | Revokes a key |
DELETE /databases/{db}/keys/{id} | the database's admins, superusers | Removes a revoked key |
GET, POST /keys, …/keys/{id}/revoke | superusers | Deployment-wide keys |
/databases/{db}/capability-keys/… | the database's admins, superusers | Token keys: register, list, revoke, remove |
PUT /databases/{db}/capabilities-not-before | the database's admins, superusers | Ends every document token issued before now |
Access management shows each with its body and how a key's creation can be retried safely.
Deployment roles
A superuser grants and revokes deployment roles
(observer, backup_operator, store_operator, auditor) to users and
to deployment-wide keys:
| Request | Does |
|---|---|
PUT /users/{name}/roles/{role} | Grants a user a role ({}); done when it holds it |
DELETE /users/{name}/roles/{role} | Revokes it |
PUT, DELETE /keys/{id}/roles/{role} | The same for a deployment-wide key |
POST /keys with { name, roles } | A key of roles alone, which holds no database permission |
# A key for a metrics scraper, answered once.
curl -u admin:"$PASSWORD" -X POST -H 'Content-Type: application/json' \
-d '{"name": "scraper", "roles": ["observer"]}' \
https://mimic.example.com/v1/admin/keysA database's own key holds no role.
Limits
| Request | Who | Does |
|---|---|---|
GET, PUT, DELETE /databases/{db}/limits | databases.read, superusers | A database's limits record |
GET, PUT, DELETE /budget-groups/{group}/limits | databases.read, superusers | A budget group's |
GET, PUT, DELETE /default-limits | databases.read, superusers | The deployment's default |
Reading takes databases.read; changing is a superuser's. See
Limits.
Collections, triggers and migrations
A database's collection registry is under /databases/{db}/collections:
reading it needs read, changing it admin. See
Schema migrations. Its webhook endpoints
(/databases/{db}/endpoints) and collections' triggers
(/databases/{db}/collections/{c}/triggers) are its admins' too.
The deployment
| Request | Who | Does |
|---|---|---|
GET /status | status.read | The deployment's status |
GET /settings | status.read | Every deployment setting, { name: { value, stored } } |
GET /stores | stores.read | The stores, their state and their partitions |
GET /operations, GET /operations/{key} | operations.read | Long-running operations: moves, drains, backups, restores, fences |
POST /operations/{key}/cancel | by kind | Cancels one where its kind allows |
GET /usage/feed | usage.read | The usage history |
GET /audit | audit.read | The audit trail |
Lost superuser credentials
With the home store's credentials, make a user an enabled superuser with a new password, creating it if absent:
MIMIC_SUPERUSER_PASSWORD=… mimicd admin superuser reset adminThe password is read from --password-file or MIMIC_SUPERUSER_PASSWORD
and hashed by the command; only the hash is written. Processes follow the
change within access_max_staleness_ms. It is audited, naming the user,
never the password. The bootstrap password changes nothing once its user
exists.