Skip to main content
Multilingual TursoDB, MVCC & AI Agent database guides Read Engine Guide →
Turso Cloud SDKs Authorization

Fine-Grained Permissions

Fine-Grained Permissions — Turso documentation.

Fine-grained permissions let you control access at the table and action level. They work with both CLI-generated tokens and JWKS-issued tokens.

Permission Format

Permissions follow the format <table-name|all>:<action1>,<action2>:

# Read-only access to all tables
turso db tokens create mydb -p all:data_read

# Specific actions on a specific table
turso db tokens create mydb -p users:data_read,data_update

# Multiple permission rules
turso db tokens create mydb \
  -p all:data_read \
  -p comments:data_add,data_update \
  -p posts:data_add,data_update,data_delete

Permission rules only grant access. There are no deny rules. Use all as the table name to apply permissions to every table.

Available Actions

Action Description
data_read Read data from tables
data_add Insert new rows
data_update Update existing rows
data_delete Delete rows
schema_add Create tables, views, indexes, and triggers
schema_update Change tables with ALTER TABLE
schema_delete Drop tables, views, indexes, and triggers
NOTE

data_read is allowed on SQLite system tables (e.g., sqlite_master, sqlite_schema) by default, allowing users to query database metadata.

WARNING

data_add also allows replacing existing rows through INSERT OR REPLACE or REPLACE INTO.

Schema Actions

Each schema statement needs a schema action on a specific table name:

Statement Action Table name in the rule
CREATE TABLE, CREATE VIEW schema_add The new table or view
CREATE INDEX, CREATE TRIGGER schema_add The table of the index or trigger
ALTER TABLE (ADD COLUMN, RENAME TO, RENAME COLUMN, DROP COLUMN) schema_update The altered table
DROP INDEX, DROP TRIGGER schema_delete The table of the index or trigger
DROP TABLE, DROP VIEW schema_delete The dropped table. DROP TABLE also requires data_delete on the table.

Example

This token can read all tables. It can change posts with ALTER TABLE, and create or drop indexes and triggers on posts. It cannot drop the posts table, because it does not have data_delete on posts:

turso db tokens create mydb \
  -p all:data_read \
  -p posts:schema_add,schema_update,schema_delete

Role-Based Access Example

You can configure your JWT template to grant different permissions based on user roles:

Role Permissions
Admin all:data_read,data_add,data_update,data_delete,schema_add,schema_update,schema_delete
Moderator all:data_read,data_update
User all:data_read

With JWKS, these permissions are embedded in the JWT token based on user metadata (e.g., role, group membership) from your auth provider.

Synced from official Turso documentation ( tursodatabase/turso-docs · MIT License) Official Docs ↗
Search
Press Esc to close · Powered by Pagefind