认证
Use Supabase to authenticate and authorize your users.
Supabase Auth 让你在应用中轻松实现身份验证和授权。我们提供客户端 SDK 和 API 接口,帮助你创建和管理用户。
🌐 Supabase Auth makes it easy to implement authentication and authorization in your app. We provide client SDKs and API endpoints to help you create and manage users.
你的用户可以使用多种流行的身份验证方法,包括密码、魔法链接、一次性密码(OTP)、社交登录和单点登录(SSO)。
🌐 Your users can use many popular Auth methods, including password, magic link, one-time password (OTP), social login, and single sign-on (SSO).
关于身份验证和授权 #
🌐 About authentication and authorization
身份验证和授权是任何认证系统的核心职责。
🌐 Authentication and authorization are the core responsibilities of any Auth system.
- 身份验证就是确认用户真的是他们声称的那个人。
- 授权是指检查用户被允许访问哪些资源。
Supabase Auth 使用 JSON Web Tokens (JWTs) 进行身份验证。有关所有 JWT 字段的完整参考,请参阅 JWT 字段参考。Auth 与 Supabase 的数据库功能集成,使得使用 行级安全 (RLS) 进行授权变得很简单。
🌐 Supabase Auth uses JSON Web Tokens (JWTs) for authentication. For a complete reference of all JWT fields, see the JWT Fields Reference. Auth integrates with Supabase's database features, making it easy to use Row Level Security (RLS) for authorization.
Supabase 生态系统 #
🌐 The Supabase ecosystem
你可以单独使用 Supabase Auth,但它也可以和 Supabase 生态系统整合使用。
🌐 You can use Supabase Auth as a standalone product, but it's also built to integrate with the Supabase ecosystem.
Auth 在后台使用你项目的 Postgres 数据库,把用户数据和其他 Auth 信息存储在一个特殊的 schema 里。你可以通过触发器和外键引用把这些数据连接到你自己的表里。
🌐 Auth uses your project's Postgres database under the hood, storing user data and other Auth information in a special schema. You can connect this data to your own tables using triggers and foreign key references.
Auth 还可以控制对你数据库自动生成的 REST API 的访问。当使用 Supabase SDK 时,你的数据请求会自动附带用户的 Auth Token。当与 RLS 策略 一起使用时,Auth Token 会在行级别上限制数据库访问。
🌐 Auth also enables access control to your database's automatically generated REST API. When using Supabase SDKs, your data requests are automatically sent with the user's Auth Token. The Auth Token scopes database access on a row-by-row level when used along with RLS policies.
Get started#
Start here if you're new to Supabase Auth:
- Sign up and sign in users with email and password.
Auth with email and password
- Create a Supabase client for SSR frameworks like Next.js and SvelteKit.
Server-side rendering
- supabase-js vs @supabase/ssr vs @supabase/server — which to use on the server.
Which package to use
- Use RLS policies to authorize data access from the client.
Row Level Security
提供者 #
🌐 Providers
Supabase Auth 支持多种流行的认证方法,包括使用第三方提供商的社交和手机号认证。请查看下列部分以获取支持的第三方提供商列表。
🌐 Supabase Auth works with many popular Auth methods, including Social and Phone Auth using third-party providers. See the following sections for a list of supported third-party providers.
社交认证 #
🌐 Social Auth
- Apple
- Azure (Microsoft)
- Bitbucket
- Discord
- Figma
- GitHub
- GitLab
- Kakao
- Keycloak
- Notion
- Slack
- Spotify
- Twitch
- WorkOS
- Zoom
你也可以通过 自定义 OAuth/OIDC 提供商 添加任何支持 OAuth2 或 OIDC 的身份提供商。
🌐 You can also add any OAuth2 or OIDC-compatible identity provider using Custom OAuth/OIDC Providers.
手机验证 #
🌐 Phone Auth
Pricing#
Charges apply to Monthly Active Users (MAU), Monthly Active Third-Party Users (Third-Party MAU), and Monthly Active SSO Users (SSO MAU) and Advanced MFA Add-ons. For a detailed breakdown of how these charges are calculated, refer to the following pages.
Next steps#
Once you've covered the basics, these guides help with other use cases and features:
- Sign up and sign in users with a Magic Link or email OTP instead of a password.
Email (Magic link or OTP)
- Add Single Sign-On for enterprise applications with SAML 2.0.
Enterprise SSO
- Control session lifetime, refresh tokens, and multi-device sign-in behavior.
User sessions
- Use Clerk, Auth0, Firebase Auth, Cognito, or WorkOS JWTs with Supabase APIs.
Third-party auth
- Add a second factor to user sign-in with TOTP or phone.
Multi-factor authentication
- Understand how Supabase Auth issues and validates JWTs.
JWTs
- Customize Auth behavior with Postgres functions at key lifecycle points.
Auth Hooks