项目简介
Logto 是一款基于 OIDC 和 OAuth 2.1 的现代开源身份认证解决方案,支持多租户、企业 SSO、RBAC 和可定制的登录流程,专为 SaaS、AI 和智能体平台设计。
README 预览
\n \n \n \n \n \n \n \n\n\n[](https://discord.gg/vRvwuwgpVX)\n[](https://github.com/logto-io/logto/actions?query=branch%3Amaster)\n[](https://github.com/logto-io/logto/releases)\n[](https://app.codecov.io/gh/logto-io/logto)\n[](https://cloud.logto.io/?sign_up=true&utm_source=github&utm_medium=repo_logto)\n[](https://gitpod.io/#https://github.com/logto-io/demo)\n[](https://render.com/deploy?repo=https://github.com/logto-io/logto)\n\n# Logto\n\n**Logto is the modern, open-source auth infrastructure for SaaS and AI apps.**\n\nIt takes the pain out of OIDC and OAuth 2.1 and makes it easy to build secure, production-ready auth with multi-tenancy, enterprise SSO, and RBAC.\n\n\n website •\n cloud •\n docs •\n api •\n blog •\n auth wiki •\n newsletter\n\n\n\n\n## Why Logto?\n\nBuilt for teams scaling SaaS, AI, and agent-based platforms without the usual auth headaches.\n\nWith Logto, you get:\n\n- **Multi-tenancy, enterprise SSO, and RBAC**: ready to use, no workarounds.\n- **Pre-built sign-in flows**, customizable UIs, and SDKs for 30+ frameworks.\n- **Full support for OIDC, OAuth 2.1, and SAML** without the protocol pain.\n- **Works out-of-the-box for Model Context Protocol and agent-based AI architectures**.\n\n[🗺️ See all features →](https://docs.logto.io/?ref=readme)\n\n## Get started\n\nPick your path:\n\n- [**Logto Cloud**](https://cloud.logto.io/?sign_up=true&ref=readme): The fastest way to try Logto. Fully managed, zero setup.\n- [**Launch Logto in GitPod**](https://gitpod.io/#https://github.com/logto-io/demo): Start Logto OSS in seconds.\n\n Wait for the message `App is running at https://3002-...gitpod.io`, then click the URL starting with `https://3002-` to continue.\n\n- **Local development:** \n\n ```bash\n # Using Docker Compose(requires Docker Desktop)\n curl -fsSL https://raw.githubusercontent.com/logto-io/logto/HEAD/docker-compose.yml | \\n docker compose -p logto -f - up\n \n # Using Node.js (requires PostgreSQL)\n
常见问题 (5)
故障排除如何修复 Logto Next.js App Router 的 Home 组件中出现的 TS1308 "await isn't allowed in non-async function" 错误?
将 Home 组件标记为 async,因为它使用了 await getLogtoContext():
const Home = async () => {
const { isAuthenticated, claims } = await getLogtoContext(logtoConfig);
// ...
};
export default Home;
然后再次运行 npm run build。Logto Console 指南中错误的非 async 示例已通过 PR #9692 修复;如果指南中仍显示 const Home = () => {,请更新 Logto。
故障排除如何解决通过 Cloudflare Zero Trust MCP Server Portal 连接 Logto MCP 时出现的 redirect_uri 400 错误?
Logto Cloud 现已支持 OAuth Client ID Metadata Documents。按如下方式配置 Cloudflare MCP 网关:
1. 在公开的 HTTPS URL 上托管一个客户端元数据 JSON 文件,例如 https://example.com/logto-mcp-client.json:
{
"client_name": "Cloudflare MCP Gateway",
"redirect_uris": [
"https://oauth-callbacks.cloudflareaccess.com/cdn-cgi/access/outbound-oauth-callback"
],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"scope": "openid",
"token_endpoint_auth_method": "none"
}
2. 在 Cloudflare MCP Server Portal 的 OAuth 配置中,将 client ID 设置为该元数据文档的完整 URL。
3. 再次连接到 https://mcp.logto.io。Logto 将获取该文档,并接受 redirect_uris 中列出的网关回调地址。
使用以下命令验证支持情况:
curl https://auth.logto.io/oidc/.well-known/openid-configuration
元数据中应包含 "client_id_metadata_document_supported": true。请勿对 Cloudflare 使用内置的 mcp-client ID,因为它仅限于 localhost 重定向 URI。
故障排除如何修复在 Logto 社交注册过程中点击 "Bind and continue" 后出现的 "session.identifier_not_found" 错误?
此问题已由 Logto PR #9593 修复。请升级到包含该修复的版本。该 bug 出现在 packages experience/src/containers/VerificationCode/use-continue-flow-code-verification.ts 中:link_social 分支在未先调用 isVerificationCodeEnabledForSignIn(type) 的情况下便提供了账户关联。修复后的代码仅在标识符支持验证码登录时才显示关联模态框;否则会显示常规的“标识符已存在”提示,并让用户返回修改。作为 Logto 1.42.0 上的临时解决方案,可以移除冲突的手机次要标识符要求,或启用手机验证码登录。请注意,当 PhoneVerificationCode 被配置为 MFA 因子时,无法启用手机验证码登录,因此必须先将其从 MFA 中移除。
how_to如何从我的应用程序强制 Logto 登录页面使用浅色或深色模式?
在发起 Logto 登录流程时,传入 theme 认证参数,值为 light 或 dark,例如 extraParams: { theme: 'dark' },或在 OIDC 授权 URL 中添加 theme=dark。当在 Logto 中启用深色模式时,此参数会覆盖默认/OS 主题;如果深色模式被禁用,该参数将被忽略。此支持在 PR #9645 中添加。
故障排除如何阻止 Logto 向注册白名单之外的邮箱发送验证码?
这种情况发生在 Logto 的统一登录/注册表单上。在验证码被验证之前,Logto 无法区分该邮箱属于已有的登录账户还是新注册用户,而过早拒绝可能会暴露账户是否存在。白名单仍会在验证之后强制执行,因此不在白名单中的邮箱无法完成注册。
要在发送验证码之前拒绝不在白名单中的邮箱,请使用显式的 sign-up/register 流程,该流程已在调用邮箱连接器之前执行白名单检查。如果统一登录路径上也需要该检查,请升级到包含 PR fix(core): check the email allowlist before sending a sign-up sign-in code 的版本,或在自托管构建中 cherry-pick 该更改并重新构建 Logto。升级后,通过提交一个不在白名单中的地址来验证修复效果:验证码请求应立即失败,且不应发送任何邮件。