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/admin on 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 status

There 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

CommandDoes
settings get, list, set NAME=VALUE …The deployment settings
statusThe deployment's status, read from its stores
stores list, add, reconcile, recountThe stores
partition move, database move, store drain, moves show, cancelMoves between stores
operations list, showThe long-running operations
database purge DB, placement DBA database's removal, and which store holds each partition
database fence, unfenceA fence of a database's home, to move it to another deployment
backup list, show, start, verify, expire, status, cancel, restoreBackups and restores
access export, importA database's users, grants and keys, carried between deployments
quarantine list, release, doc-refQuarantined documents
usage feed, history, audit readThe usage history and audit trail
pki clear-domain, clear-accountACME's records (see Network and TLS)
superuser reset NAMEA 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"
RequestWhoDoes
PUT /databases/{db}superusersCreates 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.listDatabases, a page at a time (limit 1 to 1,000)
DELETE /databases/{db}superusersRemoves it and all its documents; its id is never used again
GET /databases/{db}/purgedatabases.listIts removal read back: whether every store has dropped its rows
GET /databases/{db}/placementstores.readEach partition's store
GET, PUT /databases/{db}/access-modedatabases.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

RequestWhoDoes
POST /userssuperusers{ name, password, superuser?, roles? }
GET /userssuperusersLists users, with their roles
PUT /users/{name}/passwordsuperusers, the user itself{ password }
PUT /users/{name}/superusersuperusers{ superuser }
PUT /users/{name}/disabledsuperusers{ disabled }
DELETE /users/{name}superusersRemoves the user and its grants
GET /databases/{db}/grantsthe 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, superusersRemoves the grant

The last enabled superuser cannot be disabled, demoted or removed.

Database keys and token keys

RequestWhoDoes
POST /databases/{db}/keysthe database's admins, superusers{ name, permission }, answered { id, key } once
GET /databases/{db}/keysthe database's admins, superusersThe database's keys
POST /databases/{db}/keys/{id}/revokethe database's admins, superusersRevokes a key
DELETE /databases/{db}/keys/{id}the database's admins, superusersRemoves a revoked key
GET, POST /keys, …/keys/{id}/revokesuperusersDeployment-wide keys
/databases/{db}/capability-keys/…the database's admins, superusersToken keys: register, list, revoke, remove
PUT /databases/{db}/capabilities-not-beforethe database's admins, superusersEnds 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:

RequestDoes
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/keys

A database's own key holds no role.

Limits

RequestWhoDoes
GET, PUT, DELETE /databases/{db}/limitsdatabases.read, superusersA database's limits record
GET, PUT, DELETE /budget-groups/{group}/limitsdatabases.read, superusersA budget group's
GET, PUT, DELETE /default-limitsdatabases.read, superusersThe 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

RequestWhoDoes
GET /statusstatus.readThe deployment's status
GET /settingsstatus.readEvery deployment setting, { name: { value, stored } }
GET /storesstores.readThe stores, their state and their partitions
GET /operations, GET /operations/{key}operations.readLong-running operations: moves, drains, backups, restores, fences
POST /operations/{key}/cancelby kindCancels one where its kind allows
GET /usage/feedusage.readThe usage history
GET /auditaudit.readThe 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 admin

The 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.