> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drpn.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Two-factor sign-in

> Add an authenticator app or a passkey to your Darpan account, keep recovery codes, and sign in with a second factor or with a passkey alone.

A password alone is one leaked spreadsheet away from someone else reading your tenant's orders. Two-factor closes that gap: after your password, Darpan asks for a code from an app on your phone or a passkey on your device. Setting it up takes about two minutes, and the recovery codes you save at the end mean a lost phone is an inconvenience, not a lockout.

## Before you start

* You can sign in to Darpan with your password.
* One of these:
  * An authenticator app on your phone or computer, such as Google Authenticator, Microsoft Authenticator or 1Password.
  * A passkey or security key: Touch ID or Face ID, Windows Hello, a passkey on your phone, or a key such as a YubiKey. Passkeys appear only when your Darpan instance offers them and your browser can use them.
* Somewhere safe to keep ten recovery codes, such as a password manager.

## Who has to use it

Two-factor is optional until a super admin requires it from a date, for a role or for everyone. The roles are Super admin, Darpan admin, and Tenant admin in any tenant; everyone means every person with a tenant membership or a Darpan role.

* **Before the date:** each sign-in asks **Set up two-factor by** *date*. Choose **Set up**, or **Not now** to carry on; Darpan asks again at the next sign-in.
* **From the date:** a right password shows **Your role needs two-factor. Set it up to sign in.** You set it up there and then, and the sign-in finishes once you have. Nobody is locked out.
* **Reminders:** if you have no app or passkey yet, Darpan emails you when a date is set, again as it nears, and weekly after, never more than one a day. They stop once you set one up.

## Set it up

**1. Open User Settings**

Open **Ask Darpan** with `Cmd/Ctrl+K` or by clicking Tara, the red panda in the corner, and search for **Open User Settings**. The **Two-factor** section has an **Authenticator app** card and, when passkeys are offered, a **Passkeys** card.

At a required setup or after **Set up** at sign-in, the same steps open on the sign-in page instead, starting with **Authenticator app or passkey?**.

**2. Prove it is you**

Choose **Set up** on **Authenticator app**, or **Add** on **Passkeys**. While nothing is on yet, Darpan asks **Enter your current password.** Once a factor is on, every change asks for a code from your app or your passkey instead.

**3. Add the app or the passkey**

For an authenticator app:

1. **Scan this with your authenticator app.** Scan the QR code. If you cannot, **Can't scan? Key:** shows the key to type in, with **Copy** and **Open in app**.
2. **Enter the code it shows.** Type the 6-digit code; the sixth digit submits it.

For a passkey: **Add a passkey.** Choose **Continue** and follow your browser's prompt.

**4. Save your recovery codes**

**Save your recovery codes.** shows ten codes. Each works once, in place of a code or passkey. Use **Copy** or **Download**, store them somewhere other than this device, then choose **I saved them**. The codes are shown only this once.

## Expected result

The **Authenticator app** card reads **On since** *date* (or **On** when you also have passkeys), each passkey has its own card, and **Recovery codes** shows how many are left. Darpan emails you that an authenticator app was set up or a passkey was added.

Turning two-factor on signs you out everywhere else, CLI sign-ins included. The tab you used stays signed in. Adding a second app or passkey later ends nothing.

## Sign in

After your password, Darpan asks **Enter the code from your app.** Type the current code. To use something else:

* **Use a passkey** asks **Confirm with your passkey.** Choose **Continue** to open your browser's prompt.
* **Use a recovery code** asks **Enter a recovery code.** Each code works once, and Darpan emails you when one is used. When three or fewer remain, the sign-in tells you how many are left.

If you have only passkeys, or a passkey last confirmed you in this browser, the passkey step comes first, with **Use the app code** beside it.

If your account has no authenticator app and you sign in with a recovery code, where passkeys are offered, Darpan asks **Add a passkey on this device?** An account with the app is not asked. Choose **Add passkey** and follow your browser's prompt. The sign-in you just finished counts as the proof for 5 minutes, so no second code is asked. **Not now** skips it.

### Sign in with a passkey alone

The sign-in page asks **Username?** first. Where passkeys are offered, the username field's autofill lists the passkeys you saved for Darpan: pick one, Touch ID or Face ID confirms it, and you are in, with no password and no code.

A browser where a passkey last confirmed you remembers your account and opens on **Welcome back.** with one row: your username and **Passkey**. Choose the row and the passkey prompt opens; that one prompt signs you in. **Another account** asks **Username?** instead. A new browser asks **Username?** and then your password. After a password sign-in, or a cancelled or refused passkey, the row reads **Password** and goes to the password step.

For a security key, or a passkey on another device, choose **Use a passkey or security key** on the password step. The password and a code stay as the fallback.

## Manage your factors

All of these are in **User Settings** under **Two-factor**, and each asks for a current code or your passkey first.

| Card | Action | What it does |
| - | - | - |
| **Authenticator app** | **New app** | Moves two-factor to a new app. Asks for a code from the current one. |
| **Authenticator app** | **Turn off** | Removes the app. With passkeys left, they stay on; without, two-factor turns off. Not shown when your role requires two-factor and the app is your only factor. |
| **Passkeys** | **Add** | Adds a passkey, up to ten. |
| A passkey | Its name | Select the name to rename it, for example `MacBook Touch ID`. **Added** and **Last used** show its dates. |
| A passkey | **Remove** | Removes that passkey. Your last factor cannot be removed while your role requires two-factor. |
| **Recovery codes** | **New codes** | Replaces every unused code with ten new ones. |

Turning two-factor off signs you out everywhere else, as turning it on does.

## Approve a CLI sign-in

With two-factor on, **Approve** on the CLI approval page opens your passkey prompt when you have a passkey; **Use the app code** asks for **Current code from your app** instead. A code you have just used to sign in is refused for a few seconds; wait for the next one. See [Set up the Darpan CLI](https://docs.drpn.ai/getting-started/set-up-darpan-cli.md#sign-in).

## Lost your phone or passkey

Sign in with a recovery code, then use **New app** or **Add** to put a new factor on, and **New codes** to replace the codes you have used. With no recovery code left, ask a Darpan admin to reset your two-factor. A reset removes your app, passkeys and recovery codes and ends your sessions and CLI sign-ins; you set two-factor up again at your next sign-in if your role requires it.

## Next step

If a code or passkey is refused, see [Login and session](https://docs.drpn.ai/troubleshooting/login-and-session.md#two-factor). For session lengths and the full list of actions that ask for a fresh code, see [Auth and access](https://docs.drpn.ai/reference/auth-and-access.md#two-factor).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.