Skip to main content
CyborgDB supports role-based access control (RBAC) through per-user keys. The holder of the root index KEK can mint per-user wrapped keys that grant read and/or write access to an index.

How RBAC works

  • Per-index KEK. Each index is encrypted under a 32-byte Key-Encryption-Key (KEK), the index_key. CyborgDB wraps a data key (DEK) under the KEK internally — callers only ever handle the KEK.
  • Per-user keys. The root KEK holder calls CreateUserKeys to wrap the index key under a per-user 32-byte key (user_kek), granting read and/or write access. The set of wraps that exist defines the permission set — there is no separate permission flag. A read-only user simply has no write wrap.
  • Root-gated administration. Creating, deleting, and listing user keys always requires the root index KEK.
  • User load. A user then opens the index with their own user_kek, scoped to their user_id:
    Per-operation, the gate is enforced — a read-only user’s Upsert/Delete are rejected.
Pass a per-user key context to data operations as cyborg::KeyContext{user_kek, user_id} where user_id is a std::array<uint8_t, 16> and user_kek is a std::array<uint8_t, 32>.

CreateUserKeys

Mints per-user wrapped keys granting the requested permissions.

Parameters

At least one of grant_read / grant_write must be true.

Exceptions

  • Throws if the supplied key is not the root index KEK.
  • Throws if the user keys could not be created.

DeleteUserKeys

Revokes a user’s access by deleting their wrapped keys. Idempotent and root-gated.

Parameters

Exceptions

  • Throws if the supplied key is not the root index KEK.

ListUserKeys

Lists all users that have keys for the index and their permissions. Root-gated.

Parameters

Returns

std::vector<UserKeyInfo>: One entry per user. The UserKeyInfo struct:

Exceptions

  • Throws if the supplied key is not the root index KEK.

Example Usage