Feature: Enhance Two-Factor Authentication Plugin endpoint configuration #172

Closed
opened 2026-03-13 07:36:09 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @svaraborut on GitHub (Nov 3, 2024).

Is your feature request related to a problem? Please describe.
Currently the 2FA plugin exposes endpoints for TOTP and OTP, and both seems enabled by default, but shall be possible to disable either of the modes (currently seems only possible to disable OTP by omitting sendOTP function). Furthermore the TOTP system exposes /two-factor/get-totp-uri which is not commonly required by 2FA systems and has some serious security implications therefore shall be also possible to disable it.

Describe the solution you'd like

export const auth= betterAuth({
	plugins: [
		twoFactor({
			otpOptions: {
				enable: true,
			},
			totpOptions: {
				enable: true,
				enableSecretRecovery: true,
			}
		})
	]
})

Additional context
Many authorities are not considering Email/SMS based OTPs as a second factor anymore, the feature shall be disabled by default and a disclaimer shall be added to the documentation.

Originally created by @svaraborut on GitHub (Nov 3, 2024). **Is your feature request related to a problem? Please describe.** Currently the 2FA plugin exposes endpoints for TOTP and OTP, and both seems enabled by default, but shall be possible to disable either of the modes (currently seems only possible to disable OTP by omitting `sendOTP` function). Furthermore the TOTP system exposes `/two-factor/get-totp-uri` which is not commonly required by 2FA systems and has some serious security implications therefore shall be also possible to disable it. **Describe the solution you'd like** ```ts export const auth= betterAuth({ plugins: [ twoFactor({ otpOptions: { enable: true, }, totpOptions: { enable: true, enableSecretRecovery: true, } }) ] }) ``` **Additional context** Many authorities are not considering Email/SMS based OTPs as a second factor anymore, the feature shall be disabled by default and a disclaimer shall be added to the documentation.
Author
Owner

@Bekacru commented on GitHub (Nov 28, 2024):

Email and SMS OTPs are only enabled if you provide a sendOTP implementation. If not, they are considered disabled. And, if TOTP is enabled, recovery codes must be provided to ensure the user doesn't lose access to their account. If someone really wants to disable this, they can do so by simply disabling that request path.

@Bekacru commented on GitHub (Nov 28, 2024): Email and SMS OTPs are only enabled if you provide a `sendOTP` implementation. If not, they are considered disabled. And, if TOTP is enabled, recovery codes must be provided to ensure the user doesn't lose access to their account. If someone really wants to disable this, they can do so by simply disabling that request path.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#172