Scripts2026年5月11日·1 分钟阅读

OpenAuth — Universal Auth Server You Can Self-Host

Dax Raad's team's centralized auth server you self-host. Multi-tenant, OAuth/password/SAML/passkey. Auth0/Clerk replacement with full control.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Community
入口
Asset
安全暂存命令
npx -y tokrepo@latest install 4ef9462d-c757-48ec-93c1-db0c2835dc0c --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

简介

OpenAuth 是 Dax Raad 团队(SST / Toolbeam)做的中心化鉴权服务器 —— 自托管一台 OpenAuth server,给你所有应用签发 OAuth 兼容 token,无论用什么鉴权方式(密码、OAuth provider、SAML、passkey、magic link)。基于标准、多租户、零厂商锁定的 Auth0/Clerk 替代。适合扩展到多 app 的副业、被 Auth0 套餐价烫到的团队、想完全掌控用户库的人。任何 web 框架都行 —— TS / Python / Go / Rust / PHP。装机时间 15 分钟。


服务端(TypeScript 示例)

import { issuer } from "@openauthjs/openauth";
import { PasswordProvider } from "@openauthjs/openauth/provider/password";
import { GithubProvider } from "@openauthjs/openauth/provider/github";
import { CodeUI } from "@openauthjs/openauth/ui/code";
import { PasswordUI } from "@openauthjs/openauth/ui/password";

const auth = issuer({
  storage: { type: "dynamo", table: "openauth" },
  providers: {
    password: PasswordProvider(PasswordUI({ /* 邮箱 + 密码 UI */ })),
    github: GithubProvider({
      clientID: process.env.GITHUB_CLIENT_ID!,
      clientSecret: process.env.GITHUB_CLIENT_SECRET!,
      scopes: ["user:email"],
    }),
  },
  success: async (ctx, value) => {
    return ctx.subject("user", {
      id: value.email || value.clientID + ":" + value.id,
    });
  },
});

export const handler = auth.handler;   // 挂在 AWS Lambda / Vercel Functions

客户端(任何框架)

import { createClient } from "@openauthjs/openauth/client";

const client = createClient({
  clientID: "my-app",
  issuer: "https://auth.example.com",
});

// 跳转到登录
window.location.href = await client.authorize(
  "https://my-app.com/callback",
  "code"
);

// callback 里
const tokens = await client.exchange(code, "https://my-app.com/callback");
// tokens.access、tokens.refresh —— 标准 OAuth,到处可用

为啥用 OpenAuth 不用 Auth0/Clerk

需求 OpenAuth Auth0 Clerk
自托管 不(Private Cloud 加钱 $$$)
价格 免费(你的基建) 按 MAU 计费 $-$$$$ 按 MAU
多租户 内置
基于标准 OAuth/OIDC 原生 OAuth/OIDC 私有 + OIDC
存储 Postgres / DynamoDB / Cloudflare KV 他家 他家
锁定 无(你的 DB) 厂商 厂商

生产清单

  • 仅 HTTPS(HTTP 上 issuer 跳转炸)
  • 每 90 天轮换签名密钥(auth.rotate()
  • 短 access token(15 分钟)+ 长 refresh(30 天)
  • Cloudflare KV 或 DynamoDB 拿全球边缘延迟

FAQ

Q: 生产可用吗? A: 可以 —— Toolbeam 自己在生产跑,几个 Anthropic 周边项目也在用。还在 v1.x,可能有破坏性变更。锁定版本测升级。

Q: 存储选项? A: 内置适配器:DynamoDB(AWS 原生推荐)/ Cloudflare KV(边缘友好)/ Postgres(自托管店)/ 内存(测试)。自定义适配器约 50 行文件。

Q: 跟 Lucia / NextAuth 比? A: Lucia/NextAuth 是嵌进 app 的库。OpenAuth 是独立中心化服务器 —— 3+ 个 app 共用户时首选。一个 app 用 NextAuth 简单。多 app 组织 OpenAuth 架构更干净。


🙏

来源与感谢

Built by Toolbeam (Dax Raad's team). Licensed under MIT.

toolbeam/openauth — ⭐ 2,800+

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产