Umbral
Back to plugin directory
UR

Umbral RLS

Official by Umbral contributors

Postgres RLS, policies, FORCE isolation, request context

official beta

About

The safest tenant isolation is the kind your application code can't accidentally forget. Umbral RLS pushes it down into Postgres itself: FORCE row-level security with a per-request GUC set through the connection pool, so one request's tenant context can never leak into another's — even a buggy handler that omits a WHERE tenant_id = ... is caught by the database. It's the last line of defence, below your code, where a forgotten filter turns into zero rows instead of someone else's data.

Install

cargo add umbral-rls

Postgres only — RLS is a Postgres feature. On SQLite the plugin skips with a warning rather than silently diverging.

Wire it up

Declare a policy per protected table; the plugin sets the per-request context on the pool.

use umbral::prelude::*;
use umbral_rls::RlsPlugin;

let app = App::builder()
    .database("default", pool)
    .plugin(
        RlsPlugin::new()
            .policy("invoice", "tenant_id = current_setting('app.tenant')::bigint"),
    )
    .build()?;

Target: defence in depth for a multi-tenant SaaS

Pair it with umbral-tenants: tenants routes and scopes the request; RLS makes the database enforce the boundary even if the routing layer has a bug.

What you get

  • FORCE row-level security so table owners aren't exempt
  • Per-request GUC set through the pool — no cross-request leak
  • Policies declared in Rust, applied as migrations
  • The database enforces isolation even when a handler forgets
  • Pairs with umbral-tenants for layered multi-tenancy

Usage

Postgres only. Declare `.policy(table, sql_predicate)` per protected table on `RlsPlugin::new()`; the plugin sets a per-request GUC through the pool so a tenant's context can't leak across requests. On SQLite it skips with a warning rather than diverging.

plugin setup
cargo add umbral-rls

Feature tracker

Per-feature shipping status, recorded in the directory.

6 of 6 shipped
Enable RLS usable Beta

Turns row-level security on for selected Postgres tables.

FORCE RLS usable Beta

Applies FORCE ROW LEVEL SECURITY so table owners are not exempt.

Policy definitions usable Beta

Declare SQL USING policies per table and action.

WITH CHECK policies usable Beta

Separate write checks for insert/update paths.

Request context GUCs usable Beta

Bind per-request values through the connection pool.

SQLite production guard usable Beta

Warns or fails clearly when RLS is requested outside Postgres.

Compatibility

Declared support per Umbral version and database backend.

No compatibility rows declared yet.

Community notes

0 notes in the discussion thread.

No notes yet. Be the first to share how this plugin works for you.

Reported issues

Bugs and abuse reports filed against this plugin.

Report an issue

No open issues

No issues have been reported against this plugin. Track upstream bugs on the maintainer's tracker, or report a directory problem to the Umbral team.