Skip to main content

认证概览

🌐 Auth Overview

Mastra 让你可以选择如何处理身份验证,因此你可以使用适合你技术栈的身份系统来保护应用端点的访问。

🌐 Mastra lets you choose how you handle authentication, so you can secure access to your application's endpoints using the identity system that fits your stack.

你可以从简单的共享密钥 JWT 认证开始,当需要更高级的身份功能时,再切换到像 Supabase、Firebase Auth、Auth0、Clerk 或 WorkOS 这样的提供商。

🌐 You can start with simple shared secret JWT authentication and switch to providers like Supabase, Firebase Auth, Auth0, Clerk, or WorkOS when you need more advanced identity features.

默认行为
Direct link to 默认行为

🌐 Default behavior

在 Mastra 中,身份验证是可选的。当你配置身份验证时:

🌐 Authentication is optional in Mastra. When you configure authentication:

  • 所有内置 API 路由/api/agents/*/api/workflows/* 等)默认需要身份验证
  • 自定义 API 路由 默认也需要身份验证
  • 公共访问 可以通过 requiresAuth: false 在自定义路由上启用

如果未配置身份验证,所有路由都是公开可访问的。

🌐 If no authentication is configured, all routes are publicly accessible.

请参阅 自定义 API 路由 以控制自定义端点的身份验证。

🌐 See Custom API Routes for controlling authentication on custom endpoints.

可用提供商
Direct link to 可用提供商

🌐 Available providers

内置
Direct link to 内置

🌐 Built-in

第三方集成
Direct link to 第三方集成

🌐 Third-party integrations

高级
Direct link to 高级

🌐 Advanced