Introduction

Introduction

Adonis-2FA is a library for managing Two Factor Authentication in your AdonisJS project build on top of node-2fa.

The package it self does not store any secret or data on your behalf. It only give you access the methods to implement a two factor authentication flow and create recovery codes. You can store that information inside a database and use the auth package to login the user within your application.

But you can generate some sample codes like migrations and API controllers/routes to give you some ideas on how to implement your 2FA flow.

Installation

Install the package from the npm packages registry using one of the following commands.

npm i @nulix/adonis-2fa

Once the package is installed, you must configure it using the node ace configure command.

node ace configure @nulix/adonis-2fa

Configuration

The configuration for 2FA is stored inside the config/2fa.ts file.

See also: Adonis-2FA config stubs

import env from '#start/env'
import { defineConfig } from '@nulix/adonis-2fa'
const twoFactorAuthConfig = defineConfig({
issuer: env.get('APP_ISSUER', 'adonis'),
})
export default twoFactorAuthConfig

issuer

The name of your application that will show in the user 2FA Authenticator.