Skip to content

Authorization

RBAC Model

TensorDB provides role-based access control with table-level permissions.

Roles

RolePermissions
AdminFull access — DDL, DML, configuration
ReadWriteDML (INSERT, UPDATE, DELETE) + SELECT
ReadOnlySELECT only

Table-Level Permissions

-- Grant read access on specific tables
GRANT SELECT ON users TO role_readonly;
-- Grant write access
GRANT INSERT, UPDATE ON orders TO role_readwrite;
-- Revoke access
REVOKE ALL ON admin_logs FROM role_readwrite;

Row-Level Security

Row-level security (RLS) policies restrict which rows a user can access based on SQL predicates.

CREATE POLICY

-- Only allow users to see their own rows
CREATE POLICY user_isolation ON orders
FOR SELECT
TO analyst, viewer
USING (owner = CURRENT_USER);
-- Restrict deletes to admin role
CREATE POLICY admin_delete ON orders
FOR DELETE
TO admin
USING (1 = 1);
-- Policy for all operations
CREATE POLICY tenant_isolation ON data
FOR ALL
USING (tenant_id = CURRENT_USER);

DROP POLICY

DROP POLICY user_isolation ON orders;

Policy Operations

OperationApplies To
SELECTRead queries
INSERTInsert operations
UPDATEUpdate operations
DELETEDelete operations
ALLAll operations

Policies are stored under __meta/policy/{table}/{name} and are evaluated at query time against the session user and roles.


Audit Log

TensorDB maintains an append-only audit log of all security-relevant operations.

Querying the Audit Log

-- Show recent audit events
SHOW AUDIT LOG;
SHOW AUDIT LOG LIMIT 50;

Tracked Events

Event TypeTrigger
TableCreatedCREATE TABLE
TableDroppedDROP TABLE
IndexCreatedCREATE INDEX
IndexDroppedDROP INDEX
ViewCreatedCREATE VIEW
ViewDroppedDROP VIEW
PolicyCreatedCREATE POLICY
PolicyDroppedDROP POLICY
GdprErasureFORGET KEY
LoginUser authentication
UserCreatedUser creation
RoleGrantedRole grant
RoleRevokedRole revocation

Audit events are stored under __audit_log/ prefix with monotonically increasing sequence numbers. Events are immutable — they cannot be modified or deleted.


GDPR Erasure

The FORGET KEY command supports GDPR right-to-erasure by tombstoning all temporal versions of a record.

-- Erase all versions of a specific key
FORGET KEY 'user_123' FROM customers;

This command:

  1. Scans all temporal versions of the key in the specified table
  2. Writes empty-doc tombstones for every version found
  3. Triggers compaction to physically remove the data
  4. Records the erasure in the audit log

After erasure, historical AS OF queries will no longer return the erased key.