Two-Factor Authentication

Two-factor authentication (2FA) using Time-based One-Time Passwords (TOTP) adds an extra layer of security to user authentication.

These codes expire after a short period, making it difficult for attackers to gain unauthorized access even if passwords are compromised.

You can see the implementation below

https://github.com/madewithnovel/novel/blob/main/packages/novel/auth.js#L142arrow-up-right

https://github.com/madewithnovel/novel/blob/main/app/api/internal/v1/auth-mfa/index.tsarrow-up-right

Confugration

You will need to set up the mfa setting to true in config/auth.js.

config/auth.js
export default {
	/**
	 * Allows the use of MFA for users in the application.
	 */
	mfa: true,
}

API

You can use /auth/password/mfa to perform a Magic Link flow.

Final MFA Step

post

Proceed to the application after a successful MFA attempt.

Path parameters
strategystringRequired
Body
otpstringOptional
Responses
post
/auth/{strategy}/mfa
301

Authentication successful. Redirecting to next step...

No content

Changelog

  • 2024-12-20 - Initial Documentation

Last updated