AI AdminPanel Documentation

Turn On Two-Factor Sign-In

Two-factor sign-in asks for a six-digit code from an authenticator app (for example FreeOTP, Google Authenticator or Microsoft Authenticator) after the password. Each person turns it on for their own account. Administrators use Profile (/account), customers use Profile in the portal (/portal/profile).

The panel signs everyone in through Keycloak, so two-factor is a Keycloak setting and Keycloak asks for the code at every sign-in (AI-1438).

Platform administrators must use two-factor

Two-factor is required for platform administrators (AI-2521). A platform administrator who has no authenticator yet is asked to set one up at the next sign-in, right after the password: scan the QR code with an authenticator app and type the code. The sign-in then finishes as usual. Nobody is locked out, and an open session keeps working until the next sign-in. On a new install, the administrator who runs the setup wizard signs in once without being asked, and sets up two-factor at the sign-in after that.

Reseller staff and customers choose for themselves for now.

The reminder on your dashboard

Until two-factor is on, your dashboard (the admin dashboard, or the portal's start page for customers) shows Protect your account with two-factor authentication. Turn on two-factor starts the setup straight away (the steps below, from step 2) and brings you back to your profile at the end (AI-2236). If you do not want it now, close the reminder with the ×: it stays hidden for you in this browser. It disappears by itself once two-factor is on (AI-1850).

While the Getting started list is open on the same dashboard and has its own Turn on two-factor step, the separate reminder stays away, so the panel says it once. Hide or close the list and the reminder comes back (see First steps).

Turn it on

  1. Open your profile and find Two-factor authentication.
  2. Click Enable 2FA. You pass through the sign-in page once more. It asks for your password again only if you last typed it more than 5 minutes ago.
  3. The sign-in page shows a QR code. Scan it with your authenticator app, type the code the app shows, and confirm.
  4. Right after that, the same flow shows your recovery codes (see below): save them, tick I have saved these codes somewhere safe and click Complete setup. You can also cancel this step and set them up later from your profile.
  5. You are back on your profile, which now says two-factor is enabled and how many recovery codes are unused (AI-2236).

From now on every sign-in asks for a code from the app after the password.

While it is on

  • Change password asks for a current code as well as the current password, on Keycloak's own page.
  • Disable 2FA takes you through the sign-in page once more. It always asks for your password and a code from the app, then asks Confirm deletion. Afterwards you are back on your profile, and the next sign-in asks for the password only. Your recovery codes are removed too.

Set up recovery codes

Recovery codes let you sign in when the phone with the authenticator app is lost. Turning two-factor on shows them right away (step 4 above). If you skipped that step, or want new ones (AI-1457):

  1. On your profile, under Recovery codes, click Set up recovery codes.
  2. The sign-in page asks for your password and a code from the app (only if you last signed in more than 5 minutes ago), then shows 12 codes. They are shown only this once: copy them to a password manager, download or print them, tick I have saved these codes somewhere safe, and click Complete setup. The button stays grey until the box is ticked. Download saves a text file named after your panel's address: on demo.example.com it is demo-recovery-codes.txt.
  3. You are back on your profile, which shows how many codes are unused.

To sign in with a code: after the password, choose Try Another Way on the code page, then Recovery Authentication Code. Keycloak asks for the codes in order, by number ("Recovery code #3"). Each code works once. When few are left, or if the list may have been seen by someone else, click Create new recovery codes: the new list replaces the old one.

Lost the authenticator app

Sign in with a recovery code (see above), then on your profile click Disable 2FA and turn two-factor on again with the new phone.

Without recovery codes, ask support (your administrator or reseller) to reset your two-factor. You get an email about it, and your next sign-in asks you to set up an authenticator on the new phone.

An administrator who loses their own authenticator needs another administrator to remove it in the Keycloak admin console (Users, the user, Credentials, delete the otp entry), or the Keycloak admin account of the installation.

Reset a user's two-factor (support)

Admins, and resellers for their own customers, reset a customer user's two-factor on the customer's page: Reset two-factor (AI-1458).

Before you click it, work through this checklist. The reset is exactly what an attacker who stole a password wants, so the panel cannot decide this part for you:

  1. Verify who is asking, outside the request. Call back on a phone number you already had for this person, or confirm with someone in their company who knows them. Do not rely on the email address or phone number the caller gives you now.
  2. Write down why in the reason field: the ticket number and how you checked. It is stored in the audit log with your name and the time.
  3. Tell the user what happens next: they are signed out everywhere, and the next sign-in asks them to set up an authenticator again.

What the panel does:

  • If you last typed your password at Keycloak more than 10 minutes ago, it first asks you to sign in again (password and your own code), then brings you back to the customer's page. Just having the panel open does not count: the panel asks Keycloak when you last authenticated.
  • It first makes two-factor setup required at the user's next sign-in, then removes their authenticator and recovery codes in Keycloak (nobody, you included, sees codes), then ends all of their sessions. In that order the account is never weaker than before, even if a step fails.
  • If a step fails, the dialog says exactly what was done and what was not, the audit log records where it stopped, and you can run the reset again.
  • It emails the user ("your two-factor sign-in was reset; if you did not ask for this, contact support"). Without email configured, the dialog says that no email was sent; tell the user yourself.
  • API keys cannot reset two-factor.

For administrators

  • The setup page and its rules (six digits, a new code every 30 seconds, each code usable once) are Keycloak's defaults for the aiadminpanel realm.
  • Platform administrators get Keycloak's Configure OTP required action when they have no authenticator. The panel checks every 5 minutes, once the setup wizard is finished, and leaves anyone with an authenticator alone. The sign-in flow is not changed, so recovery codes keep working. This has no switch on a real install (AAP_KEYCLOAK_ADMIN_TWO_FACTOR=optional is for CI test runs only and is refused unless CI=true); see the upgrade guide.
  • Recovery codes are a Keycloak feature (recovery-codes, on by default since Keycloak 26.3; docker-compose.yml still lists it in KC_FEATURES). At start the panel copies Keycloak's built-in browser sign-in flow to aap browser, adds Recovery Authentication Code Form next to OTP Form (both Alternative), and makes the realm sign in with that copy. It does so only while two-factor is optional, the default; a realm with mandatory two-factor, or one signing in with a flow chosen by hand, is left as it is (recovery codes with mandatory two-factor: AI-1459; see Mandatory two-factor for how to require two-factor now). Without the feature the panel binds the realm back to the built-in flow, and AAP_KEYCLOAK_RECOVERY_CODES=off turns the whole thing off; read the upgrade guide before rolling back.
  • At sign-in, "Try another way" lists Recovery Authentication Code for everyone with an authenticator, also before they set up codes; picking it then ends with Keycloak's "credential setup required". Tell users to pick it only once their codes are set up.
  • The earlier two-factor setup under Settings → Security is gone. It used a panel-only second factor that sign-in never checked. Settings → Security now links to your profile.
  • API details: Authentication API.