The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: update auth guides (#18541)
Kang Minga5721bd6eeef
diff --git a/apps/docs/data/authProviders.ts b/apps/docs/data/authProviders.tsindex e16717d2126..b59eb38bb29 100644--- a/apps/docs/data/authProviders.ts+++ b/apps/docs/data/authProviders.ts@@ -181,6 +181,16 @@ const authProviders = [selfHosted: true,authType: 'social',},+ {+ name: 'WorkOS',+ logo: '/docs/img/icons/workos-icon',+ href: '/guides/auth/social-login/auth-workos',+ official: true,+ supporter: 'Supabase',+ platform: true,+ selfHosted: true,+ authType: 'social',+ },{name: 'Zoom',logo: '/docs/img/icons/zoom-icon',diff --git a/apps/docs/pages/guides/auth.mdx b/apps/docs/pages/guides/auth.mdxindex b92f5c23ab4..3f67d440365 100644--- a/apps/docs/pages/guides/auth.mdx+++ b/apps/docs/pages/guides/auth.mdx@@ -33,10 +33,10 @@ Here's a quick, 2 minute tour of the Auth features built-in to Supabase:You can authenticate your users in several ways:-- Email & password.-- Magic links (one-click logins).-- Social providers.-- Phone logins.+- Password-based methods such as email or phone and password+- Passwordless methods such as sending a magiclink or one-time password (OTP)+- OAuth social providers+- SAML SSO### Providersdiff --git a/apps/docs/pages/guides/auth/auth-email.mdx b/apps/docs/pages/guides/auth/auth-email.mdxindex 6416eaeeb3a..cb6bae05422 100644--- a/apps/docs/pages/guides/auth/auth-email.mdx+++ b/apps/docs/pages/guides/auth/auth-email.mdx@@ -6,17 +6,11 @@ export const meta = {description: 'Use Supabase to Authenticate and Authorize your users using email.',}-## Overview+Set up Email Logins for your Supabase application.-Setting up Email logins for your Supabase application.--- Add Email authenticator to your [Supabase Project](https://supabase.com/dashboard)-- Add the login code to your application - [JavaScript](https://github.com/supabase/supabase-js) | [Flutter](https://github.com/supabase/supabase-flutter)--## Configure email settings--1. For [Site URL](https://supabase.com/dashboard/project/_/auth/url-configuration), enter the final (hosted) URL of your app.-1. For [Auth Providers](https://supabase.com/dashboard/project/_/auth/providers), **enable email provider**.+- Enable the email provider in your [Supabase Project](/dashboard/project/_/auth/providers)+- Configure the Site URL and any additional redirect URLs in the [authentication management tab](/dashboard/project/_/auth/url-configuration).+- The Site URL represents the default URL that the user will be redirected to after clicking on the email signup confirmation link.<Admonition type="info" label="Self hosting">@@ -26,7 +20,104 @@ See the [self-hosting docs](/docs/guides/hosting/overview#configuration) for det</Admonition>-## Add login code to your client app+## Sign up the user+<Tabs+ scrollable+ size="small"+ type="underlined"+ defaultActiveId="js"+ queryGroup="language"+>+<TabPanel id="js" label="JavaScript">++To sign up the user, call [signUp()](/docs/reference/javascript/auth-signup) with their email address and password:++```js+async function signUpNewUser() {+ const { data, error } = await supabase.auth.signUp({+ email: '[email protected]',+ password: 'example-password',+ options: {+ redirectTo: 'https//example.com/welcome'+ }+ })+}+```++</TabPanel>+<TabPanel id="dart" label="Dart">++To sign up the user, call [signUp()](/docs/reference/dart/auth-signup) with their email address and password:++```dart+Future<void> signUpNewUser() async {+ final AuthResponse res = await supabase.auth.signUp(+ email: '[email protected]',+ password: 'example-password'+ );+}+```++</TabPanel>+<TabPanel id="kotlin" label="Kotlin">++To sign up the user, call [signUpWith(Email)](/docs/reference/kotlin/auth-signup) with their email address and password:++```kotlin+suspend fun signUpNewUser() {+ supabase.gotrue.signUpWith(Email) {+ email = "[email protected]"+ password = "example-password"+ }+}+```++</TabPanel>+</Tabs>++<Tabs+ scrollable+ size="small"+ type="underlined"+ defaultActiveId="js"+ queryGroup="language"+>+<TabPanel id="js" label="JavaScript">++When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:++```js+async function signOut() {+ const { error } = await supabase.auth.signOut()+}+```++</TabPanel>+<TabPanel id="dart" label="Dart">++When your user signs out, call [signOut()](/docs/reference/dart/auth-signout) to remove them from the browser session and any objects from localStorage:++```dart+Future<void> signOut() async {+ await supabase.auth.signOut();+}+```++</TabPanel>+<TabPanel id="kotlin" label="Kotlin">++When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:++```kotlin+suspend fun logout() {+ supabase.gotrue.logout()+}+```++</TabPanel>+</Tabs>++## Sign in the user<Tabsscrollable@@ -44,6 +135,9 @@ async function signInWithEmail() {const { data, error } = await supabase.auth.signInWithPassword({email: '[email protected]',password: 'example-password',+ options: {+ redirectTo: 'https//example.com/welcome'+ }})}```@@ -79,6 +173,8 @@ suspend fun signInWithEmail() {</TabPanel></Tabs>+## Sign out the user+<Tabsscrollablesize="small"@@ -110,6 +206,7 @@ Future<void> signOut() async {</TabPanel><TabPanel id="kotlin" label="Kotlin">+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:```kotlin@@ -126,6 +223,7 @@ suspend fun logout() {- [Supabase Account - Free Plan OK](https://supabase.com)- [Supabase JS Client](https://github.com/supabase/supabase-js)- [Supabase Flutter Client](https://github.com/supabase/supabase-flutter)+- [Supabase Kotlin Client](https://github.com/supabase-community/supabase-kt)export const Page = ({ children }) => <Layout meta={meta} children={children} />diff --git a/apps/docs/pages/guides/auth/auth-magic-link.mdx b/apps/docs/pages/guides/auth/auth-magic-link.mdxindex 37e8e8ead2a..4e0e228dee1 100644--- a/apps/docs/pages/guides/auth/auth-magic-link.mdx+++ b/apps/docs/pages/guides/auth/auth-magic-link.mdx@@ -3,28 +3,23 @@ import Layout from '~/layouts/DefaultGuideLayout'export const meta = {id: 'auth-magic-link',title: 'Login With Magic Link',- description: 'Use Supabase to authenticate and authorize your users using magic links.',+ description: 'Use Supabase to authenticate your users using magic links.',}-Magic links are a form of passwordless logins where users click on a link sent to their email address to log in to their accounts.-Magic links only work with email addresses. By default, a user can only request a magic link once every 60 seconds.+Magic links are a form of passwordless logins where users click on a link sent to their email address to log in to their accounts. Magic links only work with email addresses and are one-time use only. By default, a user can only request a magic link once every 60 seconds and they expire after 24 hours.-## Overview+Set up Magic Link logins for your Supabase application.-Setting up Magic Link logins for your Supabase application.+- Enable the email provider in your [Supabase Project](/dashboard/project/_/auth/providers)+- Configure the Site URL and any additional redirect URLs in the [authentication management tab](/dashboard/project/_/auth/url-configuration).+- The Site URL represents the default URL that the user will be redirected to after clicking on the email signup confirmation link.+- If a user has not signed up yet, signing in with a magic link will automatically sign up the user. To prevent users from signing up through magic links, you can set the `shouldCreateUser` option to `false`.-- Add the login code to your application - [JavaScript](/docs/reference/javascript/introduction) | [Flutter](/docs/reference/dart/installing)--## Add Magic Link into your Supabase Project--1. For [Site URL](https://supabase.com/dashboard/project/_/auth/url-configuration), enter the final (hosted) URL of your app.-1. For [Auth Providers](https://supabase.com/dashboard/project/_/auth/providers), **enable email provider**.--## Add login code to your client app+## Sign in with magic link<Admonition type="caution">-When making use of Magic Links with [the PKCE Flow](https://supabase.com/blog/supabase-auth-sso-pkce#introducing-pkce) do bear in mind that links can only be used in the same browser that they are sent from. Consequently, a magic link sent from Chrome on Desktop will be invalid if used on a Mobile Device.+When using Magic Links in [the PKCE Flow](/blog/supabase-auth-sso-pkce#introducing-pkce), keep in mind that links can only be opened from the same browser that they are sent from (as defined in the PKCE spec). Consequently, a magic link sent from Chrome on Desktop will be invalid if used on a Mobile Device.</Admonition>@@ -43,6 +38,8 @@ async function signInWithEmail() {const { data, error } = await supabase.auth.signInWithOtp({email: '[email protected]',options: {+ // set this to false if you do not want the user to be automatically signed up+ shouldCreateUser: false,emailRedirectTo: 'https://example.com/welcome',},})diff --git a/apps/docs/pages/guides/auth/social-login.mdx b/apps/docs/pages/guides/auth/social-login.mdxindex 9db34112d65..47d796b5460 100644--- a/apps/docs/pages/guides/auth/social-login.mdx+++ b/apps/docs/pages/guides/auth/social-login.mdx@@ -8,8 +8,7 @@ export const meta = {description: 'Logging in with social accounts',}-Social Login (OAuth) is an open standard for authentication that allows users to log in to one website or application using their credentials from another website or application.-It is a way for users to grant third-party applications access to their online accounts without sharing their passwords.+Social Login (OAuth) is an open standard for authentication that allows users to log in to one website or application using their credentials from another website or application. OAuth allows users to grant third-party applications access to their online accounts without sharing their passwords.OAuth is commonly used for things like logging in to a social media account from a third-party app. It is a secure and convenient way to authenticate users and share information between applications.## Benefits@@ -47,9 +46,13 @@ Supabase supports a suite of social providers. Follow these guides to configure## Provider Tokens-Once the OAuth flow completes, Supabase Auth will sign your user in. You will receive a copy of the provider token used in the OAuth flow in case you need to use it further. For example, you can use the Google provider token to access Google APIs on behalf of your user.+You can use the provider token and provider refresh token returned to make API calls to the OAuth provider. For example, you can use the Google provider token to access Google APIs on behalf of your user.++Supabase Auth does not manage refreshing the provider token for the user. Your application will need to use the provider refresh token to obtain a new provider token. If no provider refresh token is returned, then it could mean one of the following:+- The OAuth provider does not return a refresh token+- Additional scopes need to be specified in order for the OAuth provider to return a refresh token.-Provider tokens are intentionally not stored in your project's database, however. This is because provider tokens give access to potentially sensitive user data in third-party systems. Different applications have different needs, and one application's OAuth scopes may be significantly more permissive than another. If you do want to use the provider token outside of the browser that completed the OAuth flow, you will have to send it manually to a secure server under your control.+Provider tokens are intentionally not stored in your project's database. This is because provider tokens give access to potentially sensitive user data in third-party systems. Different applications have different needs, and one application's OAuth scopes may be significantly more permissive than another. If you want to use the provider token outside of the browser that completed the OAuth flow, it is recommended to send it to a trusted and secure server you control.export const Page = ({ children }) => <Layout meta={meta} children={children} />diff --git a/apps/docs/pages/guides/auth/social-login/auth-workos.mdx b/apps/docs/pages/guides/auth/social-login/auth-workos.mdxindex 29c0a8de326..4199c97b2df 100644--- a/apps/docs/pages/guides/auth/social-login/auth-workos.mdx+++ b/apps/docs/pages/guides/auth/social-login/auth-workos.mdx@@ -71,7 +71,7 @@ async function signInWithWorkOS() {queryParams: {connection: '<your_connection>',organization: '<your_organization',- provider: '<your_provider>',+ workos_provider: '<your_provider>',},},})@@ -90,7 +90,7 @@ suspend fun signInWithWorkOS() {supabase.gotrue.loginWith(WorkOS) {queryParams["connection"] = "<your_connection>"queryParams["organization"] = "<your_organization>"- queryParams["provider"] = "<your_provider>"+ queryParams["workos_provider"] = "<your_provider>"}}```diff --git a/apps/docs/pages/guides/platform/going-into-prod.mdx b/apps/docs/pages/guides/platform/going-into-prod.mdxindex 6f9ebf86fb7..27a69928d19 100644--- a/apps/docs/pages/guides/platform/going-into-prod.mdx+++ b/apps/docs/pages/guides/platform/going-into-prod.mdx@@ -60,7 +60,7 @@ After developing your project and deciding it's Production Ready, you should run### Auth Rate Limits-- The table below shows the rate limit quotas on the following authentication endpoints:+- The table below shows the rate limit quotas on the following authentication endpoints. You can configure the auth rate limits for your project [here](/dashboard/project/_/auth/rate-limits).| Endpoint | Path | Limited By | Rate Limit || ------------------------------------------------ | -------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.ymlindex f76dc993088..0a7b27ae6df 100644--- a/spec/supabase_js_v2.yml+++ b/spec/supabase_js_v2.yml@@ -620,6 +620,7 @@ functions:- Passwordless sign-ins can be resent by calling the `signInWithOtp()` method again.- Password recovery emails can be resent by calling the `resetPassswordForEmail()` method again.- This method will only resend an email or phone OTP to the user if there was an initial signup, email change or phone change request being made.+ - You can specify a redirect url when you resend an email link using the `emailRedirectTo` option.examples:- id: resend-email-signup-confirmationname: Resend an email signup confirmation@@ -630,6 +631,9 @@ functions:const { data, error } = await supabase.auth.resend({type: 'signup',email: '[email protected]'+ options: {+ emailRedirectTo: 'https://example.com/welcome'+ }})```- id: resend-phone-signup-confirmation@@ -708,9 +712,9 @@ functions:title: 'onAuthStateChange()'$ref: '@supabase/gotrue-js.GoTrueClient.onAuthStateChange'notes: |- - Types of auth events: `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `PASSWORD_RECOVERY`- - Currently, `onAuthStateChange()` does not work across tabs.- For instance, in the case of a password reset flow, the original tab which requested for the password reset link will not receive the `SIGNED_IN` and `PASSWORD_RECOVERY` event when the user clicks on the link.+ - Types of auth events: `INITIAL_SESSION`, `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `PASSWORD_RECOVERY`+ - The `INITIAL_SESSION` can be used to allow you to invoke the callback function when `onAuthStateChange` is first called.+ - Currently, `onAuthStateChange()` does not work across tabs. For instance, in the case of a password reset flow, the original tab which requested for the password reset link will not receive the `SIGNED_IN` and `PASSWORD_RECOVERY` event when the user clicks on the link.examples:- id: listen-to-auth-changes