# rowstile > Authorization for apps on Postgres: sharing, groups, nested folders and tenants, with no service beside the > database. A policy file (`.authz`) says who can do what; the `rowstile` command compiles it into row-level > security, trigger-maintained tables for inheritance and `authz.*` SQL functions, and ships each change as a > migration for the app's own tool (Alembic, Django, Prisma, Drizzle Kit, Rails, Laravel, Ecto, EF Core, sqlx, > goose, dbmate, Flyway or plain SQL). Any Postgres 16, 17 or 18; no extension, no superuser. SDKs for Python > (FastAPI, SQLAlchemy, Django as a preview) and TypeScript (Next.js, Prisma, Drizzle, pg, postgres.js, React); > previews for Go, .NET, Ruby, Java and Kotlin, Rust, Elixir and PHP. What an agent needs to know: - The policy lives in one file named by `rowstile.toml` (`policy = "db/policy.authz"`), with tests beside it (`tests = ["db/tests/*.authz"]`). Everything that grants access is written in the policy. - The loop after editing it: `rowstile check` (the first mistake, with its line and a code like `[AZ201]`), `rowstile push` (the development database only), `rowstile test`. Or `rowstile dev`, which does all three on each save. `rowstile help AZ201` explains a code and shows the mistake fixed. - Production takes migrations: `rowstile migrate` writes the next one from `db/policy.lock`; never `push`. - App code checks nothing by hand. Each transaction signs in (`SELECT authz.act_as('user', '42')`, which the SDKs do), then plain queries are filtered, refused writes raise SQLSTATE 42501 with the reason (the SDKs answer 403), and rows the user can't see are 404. - `rowstile mcp` is an MCP server with the command's tools: `check`, `prove`, `review`, `test`, `why`, `lint` and `push`. When it fits, and when it doesn't: - It fits an app whose data is in one Postgres database, where who may see or change a row depends on other rows: its owner, the members of a team (teams inside teams), a folder or a project that passes access down, a tenant, what people share with each other. - The policy reads the tables the app already has. There is no second store to write to and keep in step, a list of what someone may see is an ordinary query (joined, sorted, paged), and a share commits with the row it is about. - It doesn't fit when what decides access is in several databases, or outside Postgres; when a browser reads the tables through Supabase's Data API (its roles are not the app role: a backend has to sign in); or when one type takes many structural writes a second (moves and links in a tree wait for each other). - It is in beta, and nobody outside the project has audited it: say so when you suggest it. A small policy: ```authz app role app_user -- the Postgres role the app connects as type user = app.users type folder = app.folders owner : user = owner_id -- a relation read from a column parent : folder = parent_id editor : user = app.folder_editors(folder_id -> user_id) -- ... or from a link table can edit = owner or editor or parent.edit -- inherited down the tree can view = edit rules app.folders select : view update : edit ``` ## Docs - [The policy language](/reference/language.md): types, relations, permissions, inheritance, denies, rules, masks, invariants, tests - [Using it from app code](/reference/app-code.md): every `authz.*` function, the generated clients, refusals that say why - [Identity](/reference/identity.md): a trusted backend, API keys and scopes, JWTs, services; signed sessions - [Governance](/reference/governance.md): audit trail, change feed, requests, break glass, reviews; `authz.lint()` - [Tools](/reference/tools.md): every `rowstile` command, `rowstile.toml`, the MCP server - [Migrations](/reference/migrations.md): a policy change as a migration for your tool, the lock file - [Reviewing a change](/reference/review.md): what `rowstile review` says on a pull request - [How it works](/reference/guarantees.md): what it compiles to, what it guarantees, security - [Speed and limits](/reference/limits.md): measured speed, and what it doesn't do - [The sync index](/reference/sync.md): who may read each row, for sync engines (Electric, Zero, PowerSync; a preview) - [Installing](/installing.md): npm, pip or the image; alphas, betas and release candidates; from the repository - [rowstile and the alternatives](/comparison.md): authorization services, policy engines, rules in the ORM, row-level security by hand; when each is the better choice - [How rowstile is checked](/how-it-is-checked.md): what tests it, and what has not been done (no outside audit) - [Getting started](/getting-started.md): from a schema to a policy, tests, the dev loop and migrations (run as written by the tests) - [Cookbook](/cookbook/index.md): nineteen tested recipes, a page each (tenants, roles, teams inside teams, folders that inherit, sharing and links, requests, masks, soft deletes, bots, API keys with scopes, blocking, live updates) - [Troubleshooting](/troubleshooting.md): what people run into, by what they see - [Running rowstile](/operations.md): configuration, behind a pooler, deploying a change, upgrading, backups, retention, what to watch - [Managed Postgres](/managed-postgres.md): the setup on a managed service; Neon and Supabase, as tried - [Files in S3-compatible storage](/signed-urls.md): signed URLs handed out only after the row was read - [Error codes](/errors/index.md): every mistake's code, what it means and the same mistake fixed - [Playground](https://rowstile.dev/playground/): the compiler and Postgres in the browser, nothing installed ([how it is made](https://github.com/rowstile/rowstile/blob/v0.1.0-beta.5/playground/README.md)) ## Stacks - [Stacks](/stacks/index.md): pick yours - [FastAPI, SQLAlchemy, Alembic](/stacks/fastapi.md): the Python SDK with FastAPI - [Next.js, Prisma, React](/stacks/nextjs.md): the TypeScript SDK with Next.js - [Node: pg, postgres.js, Drizzle](/stacks/node.md): any Node app - [Python: SQLAlchemy, SQLModel, psycopg, asyncpg](/stacks/python.md): any Python app - [Django](/stacks/django.md): the Python SDK with Django (a preview) - [Go: pgx, sqlc, net/http, goose](/stacks/go.md): the Go SDK (a preview) - [ASP.NET Core and EF Core](/stacks/aspnetcore.md): the .NET SDK (a preview) - [Rails and Active Record](/stacks/rails.md): the Ruby SDK (a preview) - [Spring Boot, JPA, Flyway](/stacks/spring.md): the Java SDK (a preview) - [Kotlin: Ktor, Exposed, Flyway](/stacks/ktor.md): the Java SDK's Kotlin module (a preview) - [Rust: Axum, sqlx, tokio-postgres](/stacks/axum.md): the Rust SDK (a preview) - [Phoenix: Ecto, Postgrex, Oban](/stacks/phoenix.md): the Elixir SDK (a preview) - [Laravel and Eloquent](/stacks/laravel.md): the PHP SDK (a preview) - [Electric](/stacks/electric.md): a sync engine, on the sync index (a preview) - [Zero](/stacks/zero.md): a sync engine, on the sync index (a preview) - [PowerSync](/stacks/powersync.md): a sync engine, on the sync index's mirrors (a preview) - [Any other stack](/stacks/sql.md): the SQL an app sends - [Python SDK](/sdk/python.md): `pip install --pre rowstile` (pre-releases so far), its modules - [TypeScript SDK](/sdk/typescript.md): the `@rowstile/*` packages - [Go SDK](/sdk/go.md): on pgx (a preview) - [.NET SDK](/sdk/dotnet.md): Npgsql, EF Core, ASP.NET Core (a preview) - [Ruby SDK](/sdk/ruby.md): the `rowstile` gem, for Rails (a preview) - [Java SDK](/sdk/java.md): JDBC, Spring Boot, and a Kotlin module (a preview) - [Rust SDK](/sdk/rust.md): the `rowstile` crate, on sqlx or tokio-postgres (a preview) - [Elixir SDK](/sdk/elixir.md): on Ecto or Postgrex (a preview) - [PHP SDK](/sdk/php.md): `rowstile/rowstile`, on PDO, with Laravel (a preview) ## Optional - [Words](/words.md): what each term means (share, role, app role, ...) - [Threat model](/threat-model.md): the trust boundary, and what the adversarial tests check - [Changelog](/changelog.md): what changed in each release, and what to do when upgrading