Why turn on two-factor authentication on PrestaShop?
Short answer: because a password alone is no longer enough. It can be guessed, reused from another hacked site or stolen from an infected computer. With 2FA, a code from a device in your hand is also required.
The back office gives access to customers, orders and module installation. A stolen login can be used to export personal data or install malicious code on the shop. Two-factor authentication keeps the door shut even when the password has leaked.
What does PrestaShop offer natively to secure logins?
Short answer: a password policy, cookie settings and session management. No second factor, no failed-login limit, no back-office IP list.
| Native setting | Where | What it gives you |
|---|---|---|
| Password policy (length, minimum score) | Advanced Parameters › Security (PrestaShop 8 and 9) | Rejects weak employee and customer passwords. |
| Employee sessions | Advanced Parameters › Security | See and delete open sessions. |
| “Check the cookie’s IP address” | Advanced Parameters › Administration | Makes a stolen cookie useless from another IP; logs you out if your IP changes often. |
| Lifetime of back office cookies | Advanced Parameters › Administration | Shortens a “stay logged in” session. |
| Admin folder name | Set at installation | Makes the login address less obvious, without really protecting it. |
| Updates | Update assistant | Fixes published vulnerabilities; PrestaShop’s security policy says fixes usually target the latest release. |
How does a TOTP code work?
Short answer: the shop and your phone share a secret, sent once through a QR code. Every 30 seconds, each side computes the same 6-digit code from that secret and the time. Nothing goes through SMS.
- The method is standardised by RFC 6238, which recommends a 30-second time step and at most one step of tolerance for network delay.
- The RFC also requires that a code already accepted is not accepted a second time.
- The QR code holds an
otpauth://address that the app reads, for example:
otpauth://totp/My%20shop:mary%40example.com?secret=JBSWY3DPEHPK3PXP&issuer=My%20shopThe phone must keep accurate time: turn on automatic time. A TOTP app works offline.
Manual protections: IP list and folder name
Short answer: without a module, you can restrict the admin folder to your IPs with an .htaccess file. It is strong, but rigid if your IP changes.
# .htaccess file in the admin folder (Apache 2.4)
# Only these addresses can open the back office
Require ip 203.0.113.10
Require ip 198.51.100.0/24
Require ip 2001:db8:1:1::/64- Several
Require iplines: only one needs to match. Accepted forms (single IP, CIDR network, IPv6) are described in the Apache documentation. - Home broadband IPs change often: you may lock yourself out. Keep FTP access to fix the file.
- Behind Cloudflare or another proxy, the server sees the proxy’s IP: the rule does not work without extra setup.
- Renaming the admin folder is not protection: the address can leak (history, browser extensions, contractors).
| Measure | Against a stolen password | Against mass guessing | Risk of locking yourself out |
|---|---|---|---|
| Password policy | No | Partly | None |
| Folder name | No | Partly | None |
| IP list (.htaccess) | Yes, outside your IPs | Yes | High with a dynamic IP |
| Failed-login limit per IP | No | Yes | Low (limited wait) |
| TOTP two-factor authentication | Yes | Yes | Low with recovery codes |
Turn on back-office 2FA with Block IPs
Short answer: Block IPs adds a TOTP code after the password, 10 recovery codes, a failed-login limit, an allowed-IP list, e-mail alerts and a login journal to the back office. PrestaShop 1.7.8 or later, including the PrestaShop 9 login.
Turn on two-factor authentication for your account
- Open Block IPs › Back office.
- Click “Turn on for my account” and scan the QR code with your app (Google Authenticator, Microsoft Authenticator or another TOTP app).
- Enter the 6-digit code to confirm.
- Store the 10 recovery codes away from the phone (password manager, paper under lock). Each one works once.
- Log out and back in: after the password, the code page appears.
Require 2FA for a team
Under “Mandatory for these profiles”, tick the employee profiles concerned. At their next login, those employees must set up their app before they can open any page. Turn it on for your own account first.
Limit login attempts
On by default: 5 failures in 15 minutes (password or code) per IP. Beyond that, the IP waits for the length of the window, and the login page says so clearly. White-listed and allowed IPs are never limited. Both values can be changed.
Restrict the back office to your IPs
One IP or CIDR range per line, IPv4 or IPv6. The module refuses to save a list that does not include your current IP, so you cannot lock yourself out. Behind Cloudflare, it reads the visitor’s real IP when the connection comes from a recognised Cloudflare network.
Alerts and journal
- E-mail on a login from an unknown device (IP and browser not seen for 90 days).
- E-mail when an IP reaches the failed-login limit.
- E-mail when a recovery code is used or two-factor authentication is removed from an account.
- Login journal: successes, failures, codes, refused IPs.
The rest of the module protects the shop itself: AI crawlers, countries, IPs and fake customer accounts. Full overview on the Block IPs module page.
What if I lose my phone or lock myself out?
Short answer: three ways back in, from simplest to most radical.
- A recovery code instead of the TOTP code. An e-mail alert reports its use.
- Another administrator resets your two-factor authentication in the employee list (“Reset (lost phone)”).
- The rescue file: upload an empty file named
BLOCKIPS-RESCUEby FTP tomodules/blockips/. Every back-office (and sign-up) protection is suspended while it is there. Log in, fix the problem, then delete the file.
Back-office login checklist
- PrestaShop and modules up to date.
- One named account per employee, with the most restricted profile possible.
- Password policy on (PrestaShop 8 and 9).
- TOTP two-factor authentication for every administrator profile.
- Failed-login limit on (5 in 15 minutes by default in Block IPs).
- Allowed-IP list if your team has fixed IPs.
- Recovery codes stored, FTP access tested.
- E-mail alerts sent to an address read every day.