# PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint

> Harden FastAPI multi-tenant APIs with PostgreSQL FORCE RLS and strict RFC 9068 OIDC access-token verification.

PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint is a paid AI agent skill on Agensi by snowgem, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $19 (one-time purchase)
- Creator: [snowgem](https://www.agensi.io/creators/snowgem)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Version: 1.0
- Last updated: 2026-12-02
- Security: scan passed (2026-12-02); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/postgresql-rls-oidc-multi-tenant-security-blueprint
- Tags: backend, security, postgresql, authentication

## About this skill

Stop your AI coding agent from shipping leaky multi-tenant backends.

Standard prompts produce WHERE tenant_id = ? filters, table-owner DB roles that silently bypass RLS, session-level SET calls that leak data across pooled connections, and loose JWT checks that accept ID tokens or HS256 downgrades.

This production-hardened SKILL.md enforces an end-to-end security blueprint for FastAPI, async SQLAlchemy, Alembic, and PostgreSQL:
- True DB-level isolation: separated migrator/runtime roles (NOSUPERUSER NOBYPASSRLS), FORCE ROW LEVEL SECURITY, fail-closed GUC policies, composite tenant foreign keys, and transaction-local set_config(..., true).
- Strict RFC 9068 OIDC verification: rejects ID tokens (at+jwt only), enforces asymmetric algorithm allowlists before JWKS lookup, validates JWK algorithm match, runs off the async event loop with bounded timeouts, and redacts 503 upstream errors.
- Real proof, not mocked SQLite: ships with a self-verification checklist and real PostgreSQL + Pytest security test templates for CI.

## Requires

- Python 3.10+
- PostgreSQL
- FastAPI
- SQLAlchemy 2.x
- Alembic

## Known limitations

Targets PostgreSQL with FastAPI, async SQLAlchemy, Alembic, and OIDC resource-server bearer tokens. Not intended for SQLite-only projects, browser cookie sessions, or OAuth authorization-server implementations.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint do?

Harden FastAPI multi-tenant APIs with PostgreSQL FORCE RLS and strict RFC 9068 OIDC access-token verification.

### Which AI agents support PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint?

Connect your AI agent to Agensi through MCP, then ask it to use PostgreSQL RLS & OIDC Multi-Tenant Security Blueprint on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
