Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Auth & Multi Tenant SaaS Foundation

    1

    Design secure multi-tenant SaaS architectures with robust tenant isolation, RBAC, and adversarial test plans.

    $23.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Auth & Multi Tenant SaaS Foundation

    Auth & Multi Tenant SaaS Foundation

    Example session with this skill installed

    Plan a multi-tenant auth system for a Next.js app using Supabase. We need organizations, roles (admin/member), and tenant isolation via PostgreSQL RLS for a shared-table model.

    • Read your context and instructions
    • Compiled the auth & multi

    I have designed the multi-tenant foundation for your Next.js and Supabase stack using a shared-table isolation model with PostgreSQL Row Level Security.

    SaaS Auth & Isolation Plan

    1. Data Model & Constraints

    TableColumnsConstraints
    profilesid (PK), email, full_nameOne-to-one with auth.users
    organizationsid (PK), name, slug, created_atUnique slug
    membershipsuser_id (FK), org_id (FK), roleComposite PK (user_id, org_id)
    projectsid (PK), org_id (FK), name, dataFK to organizations

    2. Tenant Isolation (PostgreSQL RLS)

    -- Enable RLS on organization-owned data
    ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
    
    -- Policy: Users can only see projects in their active organization
    CREATE POLICY "Users can view projects in their organization"
    ON projects
    FOR SELECT
    USING (
      org_id IN (
        SELECT org_id 
        FROM memberships 
        WHERE user_id = auth.uid()
      )
    );
    
    -- Policy: Only admins can insert new projects
    CREATE POLICY "Admins can create projects"
    ON projects
    FOR INSERT
    WITH CHECK (
      EXISTS (
        SELECT 1 FROM memberships
        WHERE user_id = auth.uid()
        AND org_id = projects.org_id
        AND role = 'admin'
      )
    );
    

    3. Negative Test Matrix

    ScenarioExpected ResultVerification Method
    Cross-tenant IDOR404 / Empty SetAttempt to fetch project_id from Org B while authenticated to Org A.
    Role Escalation403 ForbiddenNon-admin user attempts POST to /api/projects.
    Stale Invitation400 Bad RequestAttempt to join organization using an expired or revoked token.
    Direct SQL LeakZero RowsQuery projects table without a valid auth.uid() context in the transaction.

    Next steps

    1. Implement the memberships table and seed the initial roles.
    2. Apply the RLS policies to all tables containing org_id.
    3. Configure the Supabase client to handle organization switching via session metadata.

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

    About this skill

    Designing a secure SaaS foundation is error-prone. One mistake in tenant isolation or session handling leads to data leaks. This skill generates a comprehensive technical implementation plan for multi-tenant authentication, authorization, and data isolation tailored to your specific stack.

    What it does

    • Trust mapping identifies actors and maps access across routes, records, and background jobs.
    • Session architecture defines OAuth/OIDC flows, rotation, revocation, and CSRF controls.
    • Organization modeling separates global identity from tenant membership with ownership transfer logic.
    • Policy definition creates an authorization matrix covering resource ownership and server-side enforcement.
    • Isolation enforcement compares shared-table keys vs. schema-per-tenant models with RLS strategies.
    • Adversarial verification generates negative test cases for IDOR, privilege escalation, and token reuse.

    How it works

    1. Provide your application stack, database, and identity provider requirements.
    2. The skill analyzes trust boundaries and tenant-isolation needs for your specific domain.
    3. It generates a detailed architecture plan including data models and API contracts.
    4. You receive a milestone-based implementation roadmap with a negative-test matrix for security verification.

    Frameworks & tools

    Works with any web stack including Node.js, Python/Django, Go, or Ruby on Rails. Compatible with identity providers like Auth0, Clerk, or Kinde, and databases supporting RLS like PostgreSQL.

    Why this beats prompting it yourself

    Standard prompts often forget edge cases like background job isolation, invitation expiry, or session revocation. This skill uses a systematic workflow to ensure no trust boundary is left unmapped and no tenant-leak vector is ignored.

    Use cases

    • Architecting a B2B SaaS from scratch with organization-based billing and permissions.
    • Migrating a single-tenant application to a multi-tenant shared-database architecture.
    • Designing granular RBAC for an enterprise platform with complex team hierarchies.
    • Hardening existing auth flows against IDOR and cross-tenant data leaks.

    Known limitations

    Does not execute code or perform live security audits. Requires manual configuration of third-party identity providers and database row-level security policies.

    Does not execute code or perform live security audits. Requires manual configuration of third-party identity providers and database row-level security policies.

    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 14 days ago

    Permissions

    Write Files
    Listed14 days ago

    What's inside

    Frequently Asked Questions

    This skill generates a comprehensive, technical architecture blueprint including data models, session flows, and security policies to ensure tenant data never leaks across boundaries.

    The skill is framework-agnostic and works with any modern stack, including Node.js, Go, or Python, as well as providers like Auth0, Clerk, or native PostgreSQL RLS.

    No, this skill provides the architectural design, API contracts, and security test plans; you will need to implement the code and configure your infrastructure based on these specifications.

    Beyond standard RBAC, you receive a 'Negative-Test Matrix' which lists specific adversarial scenarios, like IDOR and token reuse, to test against your implementation.

    This skill is ideal for B2B SaaS builders, whether you are starting a new project, migrating from single to multi-tenancy, or hardening an enterprise platform with complex team hierarchies.

    New in APIs & Backend