基于 OpenID Connect Authorization Code + PKCE 的浏览器认证,浏览器端不持有客户端密钥
ai-saas-starter — Next.js SaaS模板
作者 Tuurio
基于 Next.js 的多租户 AI SaaS 启动模板,集成 OpenID Connect 认证、流式对话、Postgres 持久化、用量控制与审计。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
服务端在数据访问前校验 JWT 签名、签发方、受众与时间声明,签发方来源作为租户边界
组织范围的会话、用量、审计事件与角色感知管理
供应商无关的流式 AI 适配器,内置不调用真实模型的 demo provider
生产使用 Postgres 持久化,本地无 DATABASE_URL 时使用重启即重置的内存存储
附带固定版本的 Tuurio provisioning CLI,用于生成公开 OIDC 客户端配置
模板详细介绍
该模板是一个面向多租户场景的 AI SaaS 启动器,使用 Next.js 构建。它把身份认证、租户隔离、流式 AI 对话和用量管理预先串联起来,适合作为自建 AI 工作台类产品的起点。
认证方面采用标准 OpenID Connect Authorization Code 流程,浏览器端使用 PKCE S256 且不持有客户端密钥;服务端在访问数据前会校验 JWT 的签名、签发方、受众与时间声明,签发方来源即租户边界。模板通过 Tuurio ID 提供身份,并附带一个固定版本的 provisioning CLI 用于生成公开 OIDC 客户端配置。
产品层面包含公开落地页与定价页、组织范围内的会话、用量、审计事件和管理功能。AI 部分是一个与供应商无关的流式适配器,内置 demo provider 会输出确定性的本地文本,不会假装调用真实模型;接入兼容的流式 chat-completions 端点时需配置 provider、base URL 和模型名。
数据存储在生产环境使用 Postgres,本地评估时若未配置 DATABASE_URL,则使用明确标注、重启即重置的内存存储。模板还包含一个进程内请求限流器,README 说明它只是起步默认值,不能替代多实例共享的生产级限流。
需要留意的是:Tuurio 身份托管在欧盟,但这不代表应用主机、数据库、AI 供应商或模型输出也在欧盟;这些服务需要自行选择并披露。仓库采用 Apache-2.0 许可,免费范围仅限该版本代码,域名、托管、数据库、支付或 AI 等外部服务可能另外收费,演示图片、字体、图标等第三方素材需单独核对许可。
适合你的项目吗?
适用场景
- 搭建面向多租户的 AI 对话工作台或内部工具
- 需要一个已接好 OIDC 登录、受保护路由与登出流程的 Next.js 起点
- 希望先以本地 demo 和内存存储评估产品流程,再接入 Postgres 与真实 AI 端点
- 需要按组织隔离会话、用量与审计记录的管理型应用
适合人群
- 具备 Next.js 与 Postgres 使用经验、准备自建 AI SaaS 的开发者或小团队
- 需要多租户隔离与用量控制,并接受自行配置身份、数据库和 AI 服务的项目
- 希望以 Apache-2.0 许可代码为基础进行修改和分发的使用者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
运行环境为 Node.js 24+,包管理器为 npm;先执行 npm ci 并复制 .env.example 为 .env.local
- 2
本地可访问 /demo 体验无需账号的浏览器端演示,该演示不发起 API 或模型请求,刷新即重置
- 3
启用真实受保护工作区需审阅并运行固定版本的 manage-tuurio-id CLI,并自行完成浏览器端安全交接
- 4
生产环境需部署获得稳定 HTTPS 源后重新运行 CLI,配置 DATABASE_URL、执行 npm run db:migrate,并将 AI_API_KEY 仅存放在服务端密钥存储中
- 5
不要向代理或聊天工具提供凭据、客户端密钥、授权码、令牌、会话 cookie 或环境文件内容
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 Apache-2.0 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发;分发时需随附 Apache-2.0 许可证。
- 修改过的文件需显著标明改动,并保留相关版权、专利、商标及归属声明。
- 若原项目附有 NOTICE 文件,分发衍生作品时需保留其中适用的归属声明。
- 许可包含适用的贡献者专利授权;发起许可所述专利诉讼会终止该专利授权,且不授予商标使用权。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- Tuurio 身份服务托管在欧盟,但这不代表应用主机、数据库、AI 供应商、提示词或模型输出也在欧盟;这些服务需自行选择并单独披露。
- 未配置 DATABASE_URL 时,已认证请求使用明确标注的内存演示存储,数据在重启后重置,仅适合本地评估。
- 未配置 AI 密钥时使用 demo provider,仅输出确定性的本地文本,不会调用真实生产模型。
- 接入真实 AI 能力需自行配置兼容的流式 chat-completions 端点、base URL 与模型名,并承担相应外部服务费用。
- 内置的进程内请求限流器只是起步默认值,多实例生产环境需自行替换为共享的限流方案。
- 启用真实受保护工作区需运行固定版本的 Tuurio provisioning CLI,并自行完成浏览器端安全交接。
- 不得向代理或聊天工具提供凭据、客户端密钥、授权码、令牌、会话 cookie 或环境文件内容。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 Apache-2.0 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
no-charge, royalty-free, irrevocable copyright license
许可证原文
Tuurio identity is hosted in the EU. This does not imply that your application host, database, AI provider, prompts, or model outputs are EU-hosted; choose and disclose those services separately.
README 原文
Without `DATABASE_URL`, authenticated requests use a visibly labelled in-memory demo store.
README 原文
Without an AI key, `AI_PROVIDER=demo` streams deterministic local copy and never pretends to call a production model.
README 原文
Set `AI_PROVIDER=openai-compatible`, `AI_BASE_URL`, and `AI_MODEL` for a compatible streaming chat-completions endpoint.
README 原文
The included in-process request limiter is a safe starter default, not a substitute for a shared production rate limiter across multiple instances.
README 原文
npx [email protected] init --framework nextjs --project-dir . --auth browser --yes --output json --campaign github_ai_saas --no-open --no-wait
README 原文
https://github.com/Tuurio/ai-saas-starter/blob/main/LICENSEhttps://github.com/Tuurio/ai-saas-starter/blob/main/README.mdNever paste credentials, client secrets, authorization codes, tokens, session cookies, or environment-file contents into an agent chat.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Next.js · React
- 网站类型
- SaaS · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-08-08
- 截图检查日期
- 2026-10-01
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: b25c0a027a8ba276ac4e81274d46671f5b63247f9b76c180377da7907fd9d78b
2026-10-01T01:16:40.503Z
来源文件 / 仓库# Tuurio AI SaaS Starter Production-oriented multi-tenant AI SaaS starter with Next.js, streaming AI, Postgres, usage controls, audit, and Tuurio ID. [](https://github.com/Tuurio/ai-saas-starter/actions/workflows/verify.yml)  > Generated from [`Tuurio/auth_samples/ai_saas_starter`](https://github.com/Tuurio/auth_samples/tree/main/ai_saas_starter). Submit implementation fixes upstream so they are not replaced by the next synchronized release. ## What you get - Standards-based OpenID Connect authentication with framework-native integration. - Exact redirect and post-logout redirect handling. - Protected-route and logout examples. - A reviewed, pinned Tuurio provisioning workflow. ## Quickstart 1. Create a repository with **Use this template** or clone this repository. 2. Follow the framework-specific prerequisites below. 3. Review and run this pinned provisioning command: ```bash npx [email protected] init --framework nextjs --project-dir . --auth browser --yes --output json --campaign github_ai_saas --no-open --no-wait ``` 4. Approve the exact command, then complete the secure browser handoff yourself. 5. Run the build and verify one real sign-in and sign-out. Never paste credentials, client secrets, authorization codes, tokens, session cookies, or environment-file contents into an agent chat. Browser and native applications are public clients and must not contain a client secret. ## Runtime and verification - Runtime: Node.js 24+ - Package manager: npm - Verification: `npm ci && npm run typecheck && npm test && npm run build && npx playwright install --with-deps chromium && npm run test:e2e` ## Security model This starter uses OpenID Connect Authorization Code flow. Browser and native clients use PKCE S256 and contain no client secret. Redirect and post-logout redirect URIs must match exactly. Identity comes from the established OIDC integration or an authenticated UserInfo request; decoded JWT payloads are never treated as validation. Keep generated local environment files ignored and never commit tokens or credentials. ## Framework instructions # Tuurio AI SaaS Starter A production-oriented, multi-tenant AI workspace with streamed conversations, tenant-isolated persistence, usage controls, role-aware administration, and Tuurio ID already wired in.  ## Product journey - Public landing and pricing pages that explain the product before sign-in. - Tuurio ID Authorization Code with PKCE for browser authentication. - Server-side JWT validation against the tenant issuer and JWKS before any data access. - Organization-scoped conversations, usage, audit events, and administration. - A provider-neutral streaming adapter with a safe built-in demo provider. - Postgres persistence in production and an explicitly labelled, reset-on-restart memory store for local evaluation. ## Quickstart 1. Install, start the app, and explore the browser-only product demo: ```bash npm ci cp .env.example .env.local npm run dev ``` Open `http://localhost:3000/demo`. The demo requires no account, makes no API or model request, and resets on refresh. Open `/setup` to get a pinned provisioning command generated for the exact origin currently in your browser. 2. To enable the real protected workspace for local development, review and run: ```bash npx [email protected] init --framework nextjs --project-dir . --base-url http://localhost:3000 --redirect-uri http://localhost:3000/auth/callback --post-logout-redirect-uri http://localhost:3000/logout/callback --public-config src/tuurio.public.json --auth browser --yes --output json --campaign github_ai_saas --no-open --no-wait ``` Complete the browser handoff yourself. Never give an agent credentials, tokens, authorization codes, session cookies, legal acceptance, or environment-file contents. 3. Restart the app after provisioning: ```bash npm run dev ``` Without `DATABASE_URL`, authenticated requests use a visibly labelled in-memory demo store. Without an AI key, `AI_PROVIDER=demo` streams deterministic local copy and never pretends to call a production model. ## Production setup 1. Deploy once to obtain the stable HTTPS origin. 2. Re-run the pinned CLI with exact production `--base-url`, `--redirect-uri`, and `--post-logout-redirect-uri` values. Commit only `src/tuurio.public.json`; it contains public OIDC client data and no secret. 3. Set `DATABASE_URL`, run `npm run db:migrate`, and store `AI_API_KEY` only in the deployment's server-side secret store. 4. Set `AI_PROVIDER=openai-compatible`, `AI_BASE_URL`, and `AI_MODEL` for a compatible streaming chat-completions endpoint. 5. Verify one real sign-in, one streamed response, tenant isolation, and sign-out. Tuurio identity is hosted in the EU. This does not imply that your application host, database, AI provider, prompts, or model outputs are EU-hosted; choose and disclose those services separately. ## Security boundaries - The browser is a public OIDC client and never receives a client secret. - The established OIDC library owns state, nonce, PKCE, callback processing, and token expiry. - APIs reject requests until the access token signature, exact issuer, intended audience, and time claims validate. - The issuer origin is the tenant boundary; every storage query also requires that tenant key. - AI provider credentials stay server-only. Prompts, model output, access tokens, and authorization codes are not logged. - The included in-process request limiter is a safe starter default, not a substitute for a shared production rate limiter across multiple instances. ## Verification ```bash npm run typecheck npm test npm run build npx playwright install chromium npm run test:e2e ``` The Postgres adapter has an integration suite as well. Start a disposable database and run `TEST_DATABASE_URL=postgres://... npm test`; the suite verifies persisted tenant isolation and atomic quota enforcement. ## License Apache-2.0. See `LICENSE` in the generated template repository. ## License Licensed under the Apache License, Version 2.0. 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 · 启动器
