Vai al contenuto

Two-factor authentication for customers: how it works and how to turn it on

Since 26.7 a customer can protect the account with a TOTP code, and since 26.9 the store can make it mandatory: enrollment and limits.

A customer account holds addresses, orders and sometimes a saved card. Protecting it with a password alone means trusting a password reused from another site. Since 26.7 the customer can switch on two factor authentication based on TOTP codes, the same mechanism the backend has used since 25.1: an authenticator app, a six digit code, and a login that asks for both.

What the store has to decide

The configuration lives in System > Configuration > Customers > Customer Configuration > Password Options and has two switches:

Setting What it does Default
Allow Two-Factor Authentication lets the customer turn 2FA on for their own account Yes
Require Two-Factor Authentication forces every customer to enroll No

The second appears only when the first is on, and both can be set per website and per store view. The difference is policy, not technology: allowing leaves the choice with the customer, requiring takes it away.

🔑 Note on the second key: backend accounts have a different switch, under System > Configuration > Advanced > Admin > Security, with a cutover date. That one is about staff, this one is about buyers.

How a customer enrolls

From their account area the customer opens the two factor page, scans the QR code with the authenticator app and confirms. The confirmation asks for two things at once: the current password and the six digit code. The password is asked again because the change is sensitive, not because the form distrusts the QR.

The QR is generated as an SVG inside the page, so no temporary file is left on the server, and the secret is stored encrypted in the database.

To turn it off the customer types the password again. When the requirement is on, Maho refuses the opt-out: that is the point where the choice stops being theirs.

🔑 Note on the second key: losing a phone does not lose the account, but it does lock the customer out. You need a support procedure, and it is better written before the first case.

What the login asks

With 2FA on, the login form behaves like the backend one: email and password first, then the code field, which only appears when the account needs it.

The same step covers the routes that skip the password. With a magic link the customer lands on a verification page before the session starts, and so it goes with social login. Whoever uses the API has to send the code together with the credentials, in a dedicated field.

🔑 Note on the second key: an extra factor must not become a weaker one. If the authenticator app is easier to guess than the password, the sum does not add up, so raising the password rules is part of the job.

What happens when 2FA is mandatory

Here sits the most interesting design decision: the requirement does not close the store. Maho puts the gate only on the sensitive parts, meaning the customer area and the checkout. Catalog, CMS pages and search stay open, so a visitor who has not enrolled yet can still browse, read and search.

Inside the gated area three things stay reachable: the enrollment page, its save action and the logout. That is the only way to let somebody out of a gate they do not have the key for yet.

🔑 Note on the second key: a gate that also blocks the page explaining how to open it is just a wall. The order here is the other way round, and it should stay that way.

Before turning the requirement on

Three things, in order.

  1. Run a full enrollment on a test account, from registration to the first order.
  2. Prepare support: whoever answers the phone has to know how to walk a customer through a lost device. The ./maho admin:user:twofa-reset command covers the backend, not the customer.
  3. Announce the requirement a few days ahead, because a customer who meets the gate at payment time does not experience security, they experience an obstacle.

Whether it is worth it

On a store selling digital goods or subscriptions, where the account is worth more than a single order, mandatory two factor is the prudent call. On an impulse driven store with guest checkout, the cost in abandoned carts can outweigh the benefit: there, keeping it optional and pushing for guest orders works better.

Text prepared with the help of AI and checked against the source before publication. It can still contain mistakes: if you find one, report it.Read the manifesto

Does your store still sell?

Tell us where you are starting from: we reply with a first assessment, no strings attached.

Ask for the store assessment