Skip to content

feat: MFA (Phone) - #1668

Merged
J0 merged 23 commits into
masterfrom
j0/add_mfa_sms
Jul 29, 2024
Merged

J0 merged 23 commits into
masterfrom
j0/add_mfa_sms

Conversation

@J0

@J0 J0 commented Jul 19, 2024 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are listed here but as a summary

enroll - enroll({factorType: 'phone', phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})
challenge - challenge({channel: '<whatsapp>'}). If no channel is specified it defaults to sms.

How it works

This is and additive change - there should be no impact on the existing flow unless one specifies {'factor_type': 'phone'} in the request body.

Key Details

  • OTP Expiry is currently tied to challenge expiry. The OTP will last as long as the challenge. We can expose an option to decouple this in the future since it is and additive change.
  • It is independent of the phone provider. You can use MFA (Phone) even if Phone Provider is disabled.
  • There is however, links to the phone provider. MFA (Phone) will derive configuration from Phone Provider (e.g. if Phone provider is configured to use Twilio, MFA (Phone) will use Twilio. If you wish to use a separate phone provider please use the Send SMS Hook.
  • OTP's are stored encrypted in the database.

Configuration

  • We have ENROLL_ENABLED and VERIFY_ENABLED toggles or both TOTP and Phone Factors.

Integration with Hooks

  • When used with the MFA Verification Hook the input payload to the hook will contain a factor type indicator:
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}

When used with the Send SMS Hook there's an indicator for the SMSType specifying that it is an MFA Hook. Use as needed.

hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}

Security Concerns

  • Vulnerability to Brute Force Attack / Distributed attack
  • Leakage of OTP Code anywhere

@coveralls

coveralls commented Jul 19, 2024 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 10150978218

Details

  • 222 of 368 (60.33%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 58.243%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/models/challenge.go 12 17 70.59%
internal/conf/configuration.go 8 17 47.06%
internal/models/factor.go 38 47 80.85%
internal/api/mfa.go 159 282 56.38%
Totals Coverage Status
Change from base Build 10146520758: 0.05%
Covered Lines: 9168
Relevant Lines: 15741

💛 - Coveralls

Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
@J0
J0 force-pushed the j0/add_mfa_sms branch from 95a9d34 to 1fb272c Compare July 19, 2024 18:31
Comment thread go.mod Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/models/factor.go Resolved
@J0
J0 force-pushed the j0/add_mfa_sms branch from ebaaa1d to 57425be Compare July 23, 2024 10:31
Comment thread internal/models/factor.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/errorcodes.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/models/factor.go Resolved
@J0

J0 commented Jul 24, 2024

Copy link
Copy Markdown
Contributor Author

Sorry folks should have followed up yesterday but stuck on debugging one test regression 😅 - there are some unpushed changes which should address most of the changes (with exception of hashing)

Push in a bit

@hf hf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just please add the encrypted string on the OTP challenge.

Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
@J0
J0 marked this pull request as ready for review July 25, 2024 12:36
@J0
J0 requested a review from a team as a code owner July 25, 2024 12:36
@J0

J0 commented Jul 25, 2024

Copy link
Copy Markdown
Contributor Author

Will do a bunch of prodding with the proposed frontend bindings before proceeding further.

Comment thread internal/api/errorcodes.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/conf/configuration.go Resolved
Comment thread internal/conf/configuration.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/conf/configuration.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/models/factor.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
Comment thread internal/api/mfa.go Resolved
hf added a commit that referenced this pull request Jul 31, 2024
… verify (#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with #1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
J0 pushed a commit that referenced this pull request Jul 31, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([#1684](#1684))
([46491b8](46491b8))
* MFA (Phone) ([#1668](#1668))
([ae091aa](ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([#1690](#1690))
([0ad1402](0ad1402))
* MFA NewFactor to default to creating unverfied factors
([#1692](#1692))
([3d448fa](3d448fa))
* minor spelling errors
([#1688](#1688))
([6aca52b](6aca52b)),
closes [#1682](#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([#1694](#1694))
([8015251](8015251))
* update mfa phone migration to be idempotent
([#1687](#1687))
([fdff1e7](fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
J0 added a commit that referenced this pull request Aug 1, 2024
## What kind of change does this PR introduce?

Complement to #1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
… verify (supabase#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with supabase#1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](supabase/auth@v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([supabase#1684](supabase#1684))
([46491b8](supabase@46491b8))
* MFA (Phone) ([supabase#1668](supabase#1668))
([ae091aa](supabase@ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([supabase#1690](supabase#1690))
([0ad1402](supabase@0ad1402))
* MFA NewFactor to default to creating unverfied factors
([supabase#1692](supabase#1692))
([3d448fa](supabase@3d448fa))
* minor spelling errors
([supabase#1688](supabase#1688))
([6aca52b](supabase@6aca52b)),
closes [supabase#1682](supabase#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([supabase#1694](supabase#1694))
([8015251](supabase@8015251))
* update mfa phone migration to be idempotent
([supabase#1687](supabase#1687))
([fdff1e7](supabase@fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
## What kind of change does this PR introduce?

Complement to supabase#1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
… verify (supabase#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with supabase#1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](supabase/auth@v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([supabase#1684](supabase#1684))
([46491b8](supabase@46491b8))
* MFA (Phone) ([supabase#1668](supabase#1668))
([ae091aa](supabase@ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([supabase#1690](supabase#1690))
([0ad1402](supabase@0ad1402))
* MFA NewFactor to default to creating unverfied factors
([supabase#1692](supabase#1692))
([3d448fa](supabase@3d448fa))
* minor spelling errors
([supabase#1688](supabase#1688))
([6aca52b](supabase@6aca52b)),
closes [supabase#1682](supabase#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([supabase#1694](supabase#1694))
([8015251](supabase@8015251))
* update mfa phone migration to be idempotent
([supabase#1687](supabase#1687))
([fdff1e7](supabase@fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
## What kind of change does this PR introduce?

Complement to supabase#1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
… verify (supabase#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with supabase#1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](supabase/auth@v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([supabase#1684](supabase#1684))
([46491b8](supabase@46491b8))
* MFA (Phone) ([supabase#1668](supabase#1668))
([ae091aa](supabase@ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([supabase#1690](supabase#1690))
([0ad1402](supabase@0ad1402))
* MFA NewFactor to default to creating unverfied factors
([supabase#1692](supabase#1692))
([3d448fa](supabase@3d448fa))
* minor spelling errors
([supabase#1688](supabase#1688))
([6aca52b](supabase@6aca52b)),
closes [supabase#1682](supabase#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([supabase#1694](supabase#1694))
([8015251](supabase@8015251))
* update mfa phone migration to be idempotent
([supabase#1687](supabase#1687))
([fdff1e7](supabase@fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
## What kind of change does this PR introduce?

Complement to supabase#1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
cemalkilic pushed a commit that referenced this pull request Aug 7, 2025
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
cemalkilic pushed a commit that referenced this pull request Aug 7, 2025
… verify (#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with #1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
cemalkilic pushed a commit that referenced this pull request Aug 7, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([#1684](#1684))
([46491b8](46491b8))
* MFA (Phone) ([#1668](#1668))
([ae091aa](ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([#1690](#1690))
([0ad1402](0ad1402))
* MFA NewFactor to default to creating unverfied factors
([#1692](#1692))
([3d448fa](3d448fa))
* minor spelling errors
([#1688](#1688))
([6aca52b](6aca52b)),
closes [#1682](#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([#1694](#1694))
([8015251](8015251))
* update mfa phone migration to be idempotent
([#1687](#1687))
([fdff1e7](fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
cemalkilic pushed a commit that referenced this pull request Aug 7, 2025
## What kind of change does this PR introduce?

Complement to #1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
xeladotbe pushed a commit to xeladotbe/supabase-auth that referenced this pull request Sep 27, 2025
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
xeladotbe pushed a commit to xeladotbe/supabase-auth that referenced this pull request Sep 27, 2025
… verify (supabase#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with supabase#1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
xeladotbe pushed a commit to xeladotbe/supabase-auth that referenced this pull request Sep 27, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](supabase/auth@v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([supabase#1684](supabase#1684))
([46491b8](supabase@46491b8))
* MFA (Phone) ([supabase#1668](supabase#1668))
([ae091aa](supabase@ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([supabase#1690](supabase#1690))
([0ad1402](supabase@0ad1402))
* MFA NewFactor to default to creating unverfied factors
([supabase#1692](supabase#1692))
([3d448fa](supabase@3d448fa))
* minor spelling errors
([supabase#1688](supabase#1688))
([6aca52b](supabase@6aca52b)),
closes [supabase#1682](supabase#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([supabase#1694](supabase#1694))
([8015251](supabase@8015251))
* update mfa phone migration to be idempotent
([supabase#1687](supabase#1687))
([fdff1e7](supabase@fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
xeladotbe pushed a commit to xeladotbe/supabase-auth that referenced this pull request Sep 27, 2025
## What kind of change does this PR introduce?

Complement to supabase#1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
fadymak pushed a commit that referenced this pull request Sep 30, 2025
## What kind of change does this PR introduce?

We introduce MFA (Phone) to allow developers to enroll a Phone-based MFA
factor. We maintain the existing pattern of enroll, challenge, verify.

The frontend bindings are [listed
here](https://github.com/supabase/auth-js/pull/932/files) but as a
summary

`enroll` - `enroll({factorType: 'phone',
phoneNumber:'<e164-phone-number>', friendlyName:'<optional-name>'})`
`challenge` - `challenge({channel: '<whatsapp>'})`. If no channel is
specified it defaults to `sms`.

### How it works

This is and additive change - there should be no impact on the existing
flow unless one specifies `{'factor_type': 'phone'}` in the request
body.

### Key Details
- OTP Expiry is currently tied to challenge expiry. The OTP will last as
long as the challenge. We can expose an option to decouple this in the
future since it is and additive change.
- It is independent of the phone provider. You can use MFA (Phone) even
if Phone Provider is disabled.
- There is however, links to the phone provider. MFA (Phone) will derive
configuration from Phone Provider (e.g. if Phone provider is configured
to use Twilio, MFA (Phone) will use Twilio. If you wish to use a
separate phone provider please use the Send SMS Hook.
- OTP's are stored encrypted in the database.

#### Configuration
- We have `ENROLL_ENABLED` and `VERIFY_ENABLED` toggles or both TOTP and
Phone Factors.

#### Integration with Hooks


- When used with the MFA Verification Hook the input payload to the hook
will contain a factor type indicator:

```
 hooks.MFAVerificationAttemptInput {
    ....
   	FactorType: 'sms'
    ....
}
```

When used with the Send SMS Hook there's an indicator for the SMSType
specifying that it is an MFA Hook. Use as needed.

```
hooks.SendSMSInput{
	User: user,
	SMS: hooks.SMS{
        ...
		SMSType: "mfa",
	},
}
```

#### Security Concerns

- Vulnerability to Brute Force Attack / Distributed attack
- Leakage of OTP Code anywhere
fadymak pushed a commit that referenced this pull request Sep 30, 2025
… verify (#1694)

`GOTRUE_MFA_ENABLED` used to control whether TOTP enroll and verify were
on, but with #1668 this config option was disregarded, meaning that TOTP
will stop working for already configured projects.
fadymak pushed a commit that referenced this pull request Sep 30, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.158.0](v2.157.0...v2.158.0)
(2024-07-31)


### Features

* add hook log entry with `run_hook` action
([#1684](#1684))
([46491b8](46491b8))
* MFA (Phone) ([#1668](#1668))
([ae091aa](ae091aa))


### Bug Fixes

* maintain backward compatibility for asymmetric JWTs
([#1690](#1690))
([0ad1402](0ad1402))
* MFA NewFactor to default to creating unverfied factors
([#1692](#1692))
([3d448fa](3d448fa))
* minor spelling errors
([#1688](#1688))
([6aca52b](6aca52b)),
closes [#1682](#1682)
* treat `GOTRUE_MFA_ENABLED` as meaning TOTP enabled on enroll and
verify ([#1694](#1694))
([8015251](8015251))
* update mfa phone migration to be idempotent
([#1687](#1687))
([fdff1e7](fdff1e7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
fadymak pushed a commit that referenced this pull request Sep 30, 2025
## What kind of change does this PR introduce?

Complement to #1668 

Add OpenAPI specification for MFA (Phone). In particular, updates the
parameters and `/enroll` `/challenge` and `/verify`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants