Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Nex Multitenant Saas Fastapi

    6

    Prevent data leaks with auto-injected SQLAlchemy tenant scoping and Cloudflare Access auth for FastAPI SaaS apps.

    $79

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    nex-multitenant-saas-fastapi

    nex-multitenant-saas-fastapi

    Example session with this skill installed

    Set up a new FastAPI SaaS core with multi-tenancy, using Cloudflare Access for auth and an initial tenant named 'Acme Corp'.

    • Read your context and instructions
    • Compiled the nex-multitenant-saas-fastapi

    I've generated the multitenant-core/ package. It includes:

    • app/database.py: SQLAlchemy listener for auto-filtering queries.
    • app/dependencies.py: Cloudflare JWT verification & tenant context injection.
    • app/models/: User and Tenant base models.

    Run python -m app.scripts.seed_tenant to begin.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Multi-Tenant Security for FastAPI

    Building a multi-tenant SaaS requires more than just adding a tenant_id column; it requires a bulletproof architecture that prevents data leaks by design. This skill generates a production-ready multi-tenancy core for FastAPI and SQLAlchemy that implements row-level isolation at the database layer.

    What it does

    • Automatic Row-Level Isolation: Uses a SQLAlchemy event listener to automatically inject WHERE tenant_id into every query. Developers literally cannot forget to scope a read.
    • "Secure by Default" Failure: The system defaults to a null tenant context. If a tenant isn't identified, queries return zero rows instead of leaking data across tenants.
    • Auditable Escape Hatches: Provides an explicit no_tenant_scope() context manager for cross-tenant admin operations, requiring a logged reason for every bypass.
    • Cloudflare Access Integration: Bundles JWT authentication with fallbacks for local development and trusted-network header modes.
    • Role-Based Access Control (RBAC): Includes three pre-defined roles (Owner, Partner, Client Viewer) with logic to handle global vs. scoped access permissions.

    Why use this skill?

    Instead of manually writing .filter(tenant_id=...) on every single endpoint—a process prone to human error—this skill applies isolation globally. It solves the "noisy neighbor" problem and data leakage concerns before you write your first business logic route. It is based on the proven architecture used in high-scale SaaS products.

    Supported Stack

    • FastAPI (Async)
    • SQLAlchemy 2.0+ (Async)
    • Pydantic v2 (Settings & Validation)
    • Cloudflare Access (Auth)
    • PostgreSQL (Shared database, row-level isolation)

    Built by Nex AI. More skills and info at nex-ai.be and slopsome.com.

    • No built-in frontend components.
    • Requires Cloudflare Access or a similar proxy for production auth.
    • Shared schema only; does not support schema-based isolation.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 3 months ago

    Permissions

    Terminal / Shell
    Listed5 months ago
    Updated3 months ago

    What's inside

    Frequently Asked Questions

    This skill prevents accidental data leaks by automatically injecting tenant-specific filters into every SQLAlchemy query, ensuring developers don't have to manually filter by 'tenant_id' for every endpoint.

    The skill is designed for the modern Python stack, specifically requiring FastAPI (Async), SQLAlchemy 2.0+, Pydantic v2, and a PostgreSQL database.

    Yes, it includes built-in integration for Cloudflare Access JWT validation, while also providing flexible fallbacks for local development and trusted-network header modes.

    You receive a production-ready architectural core containing the SQLAlchemy event listeners, scoping context managers, RBAC logic for three standard roles, and the auth middleware.

    If a tenant context isn't identified, the system is 'secure by default,' meaning queries will return zero results rather than defaulting to a global view or throwing an unhandled error.

    The skill provides a specialized 'no_tenant_scope()' context manager that allows for cross-tenant operations, designed specifically for internal admin tools or global reporting.

    New in Security