CYBORGDB_SERVICE_ROOT_KEY set, EncryptedIndex can create, list, and revoke per-index users. These methods require a client created with the root key.
See Multi-Tenancy & RBAC for the operator-side playbook (modes, key kinds, SDK-supplied indexes).
createUser
Creates a user scoped to this index and returns their API key.Parameters
Returns
Promise<{ userId, apiKey }>:
Example
listUsers
Lists the users created for this index.Returns
An array of{ userId, permissions }, where permissions is a subset of ['read', 'write'].
Example
Deleting an index doesn’t delete its user records. If you create a new index with the same name,
listUsers() on it still returns the old users. They can’t read the new index, because their keys don’t unwrap its data key; delete them with deleteUser().deleteUser
Revokes a user. Their access keys for this index are erased, so theircdbk_ key stops working on the next request.
Parameters
Example
Exceptions
These apply to all three methods:CyborgDBAuthenticationError
CyborgDBAuthenticationError
The client isn’t using the root key (HTTP
403), or its apiKey is invalid (HTTP 401).CyborgDBValidationError
CyborgDBValidationError
permissions is empty or contains a value other than 'read' or 'write', or userId isn’t hex (HTTP 400).CyborgDBNotFoundError
CyborgDBNotFoundError
The index doesn’t exist (HTTP
404).CyborgDBServiceError
CyborgDBServiceError
The service returns
5xx.