Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: add MFA methods (#20098)

Joel Leea423ff201d98
diff --git a/apps/docs/spec/supabase_py_v2.yml b/apps/docs/spec/supabase_py_v2.yml
index 70c86d73440..0da348f884b 100644
--- a/apps/docs/spec/supabase_py_v2.yml
+++ b/apps/docs/spec/supabase_py_v2.yml
@@ -62,7 +62,7 @@ functions:
- If sign_up() is called for an existing confirmed user:
- If **Confirm email** is enabled in [your project](https://supabase.com/dashboard/project/_/auth/providers), an obfuscated/fake user object is returned.
- If **Confirm email** is disabled, the error message, `User already registered` is returned.
- - To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
+ - To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/python/auth-getuser).
examples:
- id: signup
name: Sign up
@@ -216,6 +216,105 @@ functions:
```
res = supabase.auth.verify_otp(phone, token)
```
+ - id: auth-mfa-api
+ title: 'Overview'
+ notes: |
+ This section contains methods commonly used for Multi-Factor Authentication (MFA) and are invoked behind the `supabase.auth.mfa` namespace.
+
+ Currently, we only support time-based one-time password (TOTP) as the 2nd factor. We don't support recovery codes but we allow users to enroll more than 1 TOTP factor, with an upper limit of 10.
+
+ Having a 2nd TOTP factor for recovery frees the user of the burden of having to store their recovery codes somewhere. It also reduces the attack surface since multiple recovery codes are usually generated compared to just having 1 backup TOTP factor.
+ - id: mfa-enroll
+ title: 'mfa.enroll()'
+ notes: |
+ - Currently, `totp` is the only supported `factor_type`. The returned `id` should be used to create a challenge.
+ - To create a challenge, see [`mfa.challenge()`](/docs/reference/python/auth-mfa-challenge).
+ - To verify a challenge, see [`mfa.verify()`](/docs/reference/python/auth-mfa-verify).
+ - To create and verify a challenge in a single step, see [`mfa.challenge_and_verify()`](/docs/reference/python/auth-mfa-challengeandverify).
+ examples:
+ - id: enroll-totp-factor
+ name: Enroll a time-based, one-time password (TOTP) factor
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.enroll({
+ "factor_type": "totp",
+ "friendly_name": "your_friendly_name"
+ })
+ ```
+ - id: mfa-challenge
+ title: 'mfa.challenge()'
+ notes: |
+ - An [enrolled factor](/docs/reference/python/auth-mfa-enroll) is required before creating a challenge.
+ - To verify a challenge, see [`mfa.verify()`](/docs/reference/python/auth-mfa-verify).
+ examples:
+ - id: create-mfa-challenge
+ name: Create a challenge for a factor
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.challenge({
+ "factor_id": '34e770dd-9ff9-416c-87fa-43b31d7ef225'
+ })
+ ```
+ - id: mfa-verify
+ title: 'mfa.verify()'
+ notes: |
+ - To verify a challenge, please [create a challenge](/docs/reference/python/auth-mfa-challenge) first.
+ examples:
+ - id: verify-challenge
+ name: Verify a challenge for a factor
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.verify({
+ "factor_id": '34e770dd-9ff9-416c-87fa-43b31d7ef225',
+ "challenge_id": '4034ae6f-a8ce-4fb5-8ee5-69a5863a7c15',
+ "code": '123456'
+ })
+ ```
+ - id: mfa-challenge-and-verify
+ title: 'mfa.challenge_and_verify()'
+ notes: |
+ - An [enrolled factor](/docs/reference/python/auth-mfa-enroll) is required before invoking `challengeAndVerify()`.
+ - Executes [`mfa.challenge()`](/docs/reference/python/auth-mfa-challenge) and [`mfa.verify()`](/docs/reference/python/auth-mfa-verify) in a single step.
+ examples:
+ - id: challenge-and-verify
+ name: Create and verify a challenge for a factor
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.challenge_and_verify({
+ "factor_id": '34e770dd-9ff9-416c-87fa-43b31d7ef225',
+ "code": '123456'
+ })
+ ```
+ - id: mfa-unenroll
+ title: 'mfa.unenroll()'
+ examples:
+ - id: unenroll-a-factor
+ name: Unenroll a factor
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.unenroll({
+ "factor_id": '34e770dd-9ff9-416c-87fa-43b31d7ef225',
+ })
+ ```
+ - id: mfa-get-authenticator-assurance-level
+ title: 'mfa.get_authenticator_assurance_level()'
+ notes: |
+ - Authenticator Assurance Level (AAL) is the measure of the strength of an authentication mechanism.
+ - In Supabase, having an AAL of `aal1` refers to having the 1st factor of authentication such as an email and password or OAuth sign-in while `aal2` refers to the 2nd factor of authentication such as a time-based, one-time-password (TOTP).
+ - If the user has a verified factor, the `next_level` field will return `aal2`, else, it will return `aal1`.
+ examples:
+ - id: get-aal
+ name: Get the AAL details of a session
+ isSpotlight: true
+ code: |
+ ```
+ res = await supabase.auth.mfa.get_authenticator_assurance_level()
+ ```
- id: get-user
title: 'get_user'
notes: |
@@ -1988,7 +2087,7 @@ functions:
- id: from-get-public-url
title: 'from_.get_public_url()'
notes: |
- - The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
+ - The bucket needs to be set to public, either via [updateBucket()](/docs/reference/python/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
- RLS policy permissions required:
- `buckets` table permissions: none
- `objects` table permissions: none