row-level-security-patterns

Community

Enforce per-tenant access with PostgreSQL RLS.

Authormarquesfelip
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Row-level security patterns address tenant isolation at the database layer for multi-tenant apps, preventing data leakage across tenants by enforcing access policies.

Core Features & Use Cases

  • Enables ROW LEVEL SECURITY on tenant-scoped tables and forces RLS to ensure policy enforcement.
  • Defines separate READ (USING) and WRITE (WITH CHECK) policies tied to per-tenant context.
  • Sets per-transaction tenant context using SET LOCAL or set_config, avoiding leakage with connection pools.
  • Provides admin/migration bypass patterns using dedicated roles and SECURITY DEFINER functions for privileged operations.
  • Includes testing strategies to validate cross-tenant isolation and absence of data leakage.

Quick Start

Enable RLS on tenant-scoped tables, define USING and WITH CHECK policies referencing current_setting('app.tenant_id', TRUE), and enforce tenant context per transaction with set_config('app.tenant_id', 'tenant-id', TRUE) and SET LOCAL.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: row-level-security-patterns
Download link: https://github.com/marquesfelip/agents-and-skills/archive/main.zip#row-level-security-patterns

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.