SPB Git

Repository Public

002_connect.sql 2.5 KB 35 lines sql

1-- SP Vault Connect / Agents. NOT zero-knowledge: values of managed secrets are decryptable by the managed-secrets2-- process on the node (services/managed-secrets/THREAT_MODEL.md). Kept apart from the personal vault tables.3create table service_accounts (4  id uuid primary key, account_id uuid not null references accounts on delete cascade, name text not null,5  kind text not null check (kind in ('service','agent')), pub text not null,6  created_at timestamptz not null default now(), revoked_at timestamptz, last_used_at timestamptz7);8create index on service_accounts (account_id);9create table managed_secrets (10  id uuid primary key, account_id uuid not null references accounts on delete cascade, name text not null,11  kind text not null check (kind in ('http-bearer','http-header','http-basic','hmac','raw')), config jsonb not null default '{}',12  version int not null default 1, created_at timestamptz not null default now(), rotated_at timestamptz not null default now(),13  rotate_every_days int, expires_at timestamptz, deleted_at timestamptz14);15create index on managed_secrets (account_id);16create table agent_grants (17  id uuid primary key, account_id uuid not null references accounts on delete cascade,18  service_account_id uuid not null references service_accounts on delete cascade, secret_id uuid not null references managed_secrets on delete cascade,19  mode text not null check (mode in ('operate','read')), approval text not null check (approval in ('never','lease','each')),20  lease_ttl_sec int not null default 300, max_uses int, uses int not null default 0, rate_per_min int not null default 30,21  constraints jsonb not null default '{}', expires_at timestamptz not null, revoked_at timestamptz, created_at timestamptz not null default now()22);23create index on agent_grants (service_account_id);24create table agent_approvals (25  id uuid primary key, account_id uuid not null references accounts on delete cascade, grant_id uuid not null references agent_grants on delete cascade,26  summary jsonb not null, status text not null default 'pending' check (status in ('pending','approved','denied','expired','used')),27  created_at timestamptz not null default now(), expires_at timestamptz not null, decided_at timestamptz, decided_by uuid28);29create index on agent_approvals (account_id, status);30create table agent_leases (31  id uuid primary key, grant_id uuid not null references agent_grants on delete cascade, approval_id uuid,32  expires_at timestamptz not null, revoked_at timestamptz, created_at timestamptz not null default now()33);34create index on agent_leases (grant_id);35
Files main
Menu

Theme