自带 74 个 pgtap 行级安全策略测试,针对 5 工作区 × 8 用户 × 全角色 × 全表的敌对夹具
cinderblock — Next.js SaaS模板
作者 philiprehberger
基于 Supabase 与 Next.js 的可分叉多租户 SaaS 启动器,核心是一套针对敌对多租户数据夹具的 pgtap 行级安全(RLS)策略测试。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
Postgres 数据模型覆盖工作区、成员、角色、邀请、审计与账单
支持魔法链接、Google OAuth 与 owner 的 TOTP 多因素认证
管理员模拟登录使用 60 分钟服务端签发 HS256 JWT,入口 step-up 认证,审计双重记录
Stripe Checkout 与 Customer Portal 以测试模式接入,webhook 采用先插入幂等
提供读取 pg_policies 的实时策略查看页与最新 pgtap 结果页
模板详细介绍
Cinderblock 是一个可 fork 的多租户 SaaS 启动模板,运行在 Supabase 与 Next.js 之上。它的重点不在界面,而在数据隔离:仓库自带一套 74 个 pgtap 策略测试,针对 5 个工作区 × 8 个用户 × 全部角色 × 全部表的敌对夹具运行,跨租户查询应返回 0 行,任何一行泄漏都会让测试失败。
数据模型覆盖工作区、成员、角色、邀请、审计与账单,建在 Postgres 上。认证方式包括魔法链接、Google OAuth,以及面向 owner 的 TOTP 多因素认证。管理员可进行带 60 分钟服务端签发 HS256 JWT 的模拟登录,进入时需 step-up 认证,审计事件双重记录。审计写入通过直连的 cb_audit_writer Postgres 连接完成,不走 Edge Function 往返。
计费部分接入 Stripe Checkout 与 Customer Portal,运行在测试模式,webhook 采用先插入的幂等处理,席位限制使用延迟触发器,并包含逾期宽限与取消后只读两种状态。
仓库还提供两个在线文档页:/docs/security/policies 读取已部署数据库的 pg_policies 展示实时策略,/docs/security/test-results 展示最近一次捕获的 pgtap 输出。README 说明 pgtap 套件是核心产物,`npx supabase test db` 可在自己的 fork 中复现绿色结果。
限制方面:模板依赖 Supabase、Stripe 等外部服务,这些服务可能另行收费;演示图片、字体、图标等第三方素材需按各自许可核对。README 中的首次运行时间与缓存后速度属于作者自述,未在本资料中独立验证。
适合你的项目吗?
适用场景
- 需要验证多租户数据隔离策略是否真的生效的 SaaS 项目
- 希望以 Supabase 为后端搭建工作区、成员、角色与邀请体系
- 需要审计日志与管理员模拟登录能力的后台系统
- 计划接入 Stripe 订阅计费并需要 webhook 幂等处理的场景
适合人群
- 熟悉 Next.js 与 Supabase、愿意自行配置外部服务的开发者
- 把行级安全与跨租户隔离作为首要评估点的团队
- 需要可 fork 并自行运行安全测试套件的项目
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后执行 npm install,再运行 ./scripts/postclone.sh(或 npm run postclone),最后 npm run dev
- 2
postclone.sh 会启动 Supabase、应用迁移、生成 cb_audit_writer 与 cb_impersonator 密码、生成 Edge Function HMAC 密钥并运行 pgtap 套件,任一失败即非零退出
- 3
首次运行需拉取 supabase start 的 Docker 镜像,README 称约 10–15 分钟,后续运行更快
- 4
Supabase、Stripe 等外部服务可能产生额外费用,需自行准备账号与密钥
- 5
演示图片、字体、图标等第三方素材需按各自许可单独核对
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- Stripe 计费功能仅在测试模式下接入,正式收款需自行配置 Stripe 账号与密钥,可能产生外部服务费用。
- 模板依赖 Supabase Cloud 外部服务,需自行注册账号并可能产生费用。
- 首次运行需拉取 Docker 镜像,耗时约 10–15 分钟,需本地具备 Docker 环境。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
Stripe Checkout + Customer Portal wired in test mode with insert-first webhook idempotency.
README 原文
Supabase Cloud (Postgres 17, Auth, Edge Functions, Storage, Realtime)
README 原文
https://github.com/philiprehberger/cinderblock/blob/main/LICENSEhttps://github.com/philiprehberger/cinderblock/blob/main/README.mdFirst run is 10–15 minutes (Docker image pull for `supabase start`).
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-07。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Next.js · React
- 网站类型
- SaaS · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-28
- 截图检查日期
- 2026-10-07
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-08
查看当时使用的来源资料
SHA-256: b73aebb0c2458ee176cad8635495f2b1e04c7ca2e8bcc4f152e9781271e22468
2026-10-07T19:06:29.002Z
来源文件 / 仓库# Cinderblock The forkable multi-tenant SaaS starter on Supabase whose load-bearing differentiator is a pgtap-tested Row-Level-Security suite that survives hostile multi-tenant fixtures. Most Supabase multi-tenant deliveries trust the client to send the right tenant ID, use the service-role key to bypass RLS "for performance," or write policies that pass against the owner's own data and silently leak under joins. Cinderblock doesn't. ## What you get - Workspace + member + role + invite + audit + billing data model on Postgres. - 74 pgtap policy tests against a hostile fixture (5 workspaces × 8 users × every role × every table). Cross-tenant attempts return 0 rows; the tests fail loudly if a single row leaks through. - Magic-link + Google OAuth + TOTP MFA on owners. - Admin impersonation with a 60-minute server-minted HS256 JWT, step-up auth on entry, and double-logged audit events. - Stripe Checkout + Customer Portal wired in test mode with insert-first webhook idempotency. Seat enforcement deferred trigger. Past-due grace + canceled read-only modes. - A direct `cb_audit_writer` Postgres connection for append-only audit writes (no Edge Function round-trip per server action). - `/docs/security/policies` — a live RLS policy viewer that reads `pg_policies` on the deployed database. - `/docs/security/test-results` — the latest captured pgtap output. The pgtap suite is the load-bearing artifact: `npx supabase test db` produces a green run a prospect can reproduce in their own fork in under a minute (warm cache). ## Quick start ```bash git clone https://github.com/philiprehberger/cinderblock.git cd cinderblock npm install ./scripts/postclone.sh # or `npm run postclone` npm run dev ``` `postclone.sh` is idempotent — it boots Supabase, applies migrations, generates passwords for `cb_audit_writer` + `cb_impersonator`, generates Edge Function HMAC secrets, runs the pgtap suite, and exits non-zero if anything is red. First run is 10–15 minutes (Docker image pull for `supabase start`). Subsequent runs are under a minute. ## Docs - [Overview](https://cinderblock.philiprehberger.com/docs) - [Getting started](https://cinderblock.philiprehberger.com/docs/getting-started) - [How RLS works](https://cinderblock.philiprehberger.com/docs/security/rls) - [Live policy viewer](https://cinderblock.philiprehberger.com/docs/security/policies) - [Test results](https://cinderblock.philiprehberger.com/docs/security/test-results) - [Audit log + impersonation](https://cinderblock.philiprehberger.com/docs/security/audit-log) - [Policy evaluation cost](https://cinderblock.philiprehberger.com/docs/security/policy-cost) - [Disclaimer](https://cinderblock.philiprehberger.com/docs/security/disclaimer) - [Stripe wiring](https://cinderblock.philiprehberger.com/docs/billing/stripe) - [Swap to Vercel](https://cinderblock.philiprehberger.com/docs/swap-vercel) ## Stack - Next.js 16 (App Router) + React 19 + Tailwind 4 + TypeScript strict - Supabase Cloud (Postgres 17, Auth, Edge Functions, Storage, Realtime) - Stripe (Checkout + Customer Portal + webhook idempotency) - pgtap for the security suite, Vitest for TypeScript units, Playwright for E2E ## License MIT. See [LICENSE](./LICENSE).
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
