Overview
Login Security adds a second sign-in step to your OpenCart store, for administrators and customers. After the password, people confirm with a 6-digit code from an authenticator app or with a passkey (fingerprint, face, screen lock or a security key). A leaked or guessed password is no longer enough to take over an admin account or a customer account with saved addresses and order history.
- Authenticator apps (TOTP, RFC 6238): Google Authenticator, Microsoft Authenticator, 1Password, Authy, Bitwarden and any app with 6-digit codes. The QR code is drawn on your own server; the secret never leaves it and is stored encrypted (AES-256-GCM; the key is derived from a random secret in the extension's own
kv_ls_meta table, made at install and kept on uninstall). - Passkeys (WebAuthn): platform passkeys (Windows Hello, Touch ID, Face ID, Android screen lock, synced passkeys in iCloud Keychain or Google Password Manager) and roaming security keys (USB / NFC keys). No library and no outside service: the browser's own WebAuthn API, verified on your server.
- 10 recovery codes per account, shown once, stored only as keyed hashes, each works once.
- Trusted devices: "Don't ask again on this device for 30 days" (0 - 365 days, or off), with "Sign out all trusted devices". Can be switched off for administrators only.
- Policies per side: for administrators and for customers separately: off, optional, required for everyone, or required for chosen admin user groups / customer groups. Required accounts set it up right after their password at the next sign-in, so nobody is locked out.
- Lockout with a log: after 5 wrong codes (3 - 10) the second step is locked for 15 minutes (5 - 60), and after 20 wrong codes in 24 hours for the rest of that day. A recovery code still works while the step is locked (and ends the lock); recovery codes have their own limit of 10 tries per account and hour. The password is always needed first. Every second step, wrong code, lock, set-up, removal and reset is in the security log.
- Changes need a fresh proof: removing the authenticator app or a passkey, adding a method to an account that already has one and making new recovery codes ask for a current code, recovery code or passkey first (valid 5 minutes).
- Admin reset per user: the Administrators and Customers tabs show who uses two-step sign-in; reset or unlock an account with one click. The user edit form shows the state too.
- Every sign-in path: the customer step works for the login page, the checkout login, the affiliate login and sign-ins made by other extensions (social sign-in), because it checks the signed-in customer on every page, not one form: until the step is passed the customer is signed out again and cannot open any account page (the extension's own Two-step sign-in page included). OpenCart's "Login into Store" from the admin customer list skips the customer's step (the administrator is already verified).
- No core edits: events only on OpenCart 4 and 3. The OpenCart 3 package has the
install.xml that the installer expects, without any modification rules. Uninstall keeps every user's factors, the log and the settings, so updates never lock anyone out.
| Page | Contents |
|---|
| Installation | Requirements, install, update, uninstall, permissions |
| Configuration | Every setting |
| Usage | Setting up, signing in, passkeys, recovery, the admin tabs, locked out |
| Developer notes | Standards, sign-in flow, data model, events |
| FAQ | Common questions |
Compatibility
| |
|---|
| OpenCart | 4.1.0.x (tested on 4.1.0.4) and 3.0.3.x - 3.0.5.x (tested on 3.0.5.1) |
| PHP | 7.4 or newer (OpenCart 4.1 and 3.0.5 need 8.1+) with OpenSSL |
| Themes | Any theme: the storefront pages use the theme's header and footer and their own scoped styles |
| Passkeys | Any current browser; HTTPS on your store domain (or localhost for testing) |
| Other extensions | Security & Anti-Spam by Kavio Labs has its own admin two-step sign-in. Administrators who set it up there (or whom it requires) are asked by Security & Anti-Spam only; every other administrator is asked by this extension, so nobody is asked twice and nobody is skipped. Customers are always protected by this extension |
Installation
Requirements: OpenCart 4.1.0.x (tested on 4.1.0.4) and 3.0.3.x - 3.0.5.x (tested on 3.0.5.1), PHP 7.4 or newer with OpenSSL (8.1+ for OpenCart 4.1 and 3.0.5). Passkeys need HTTPS on the store domain. Other OpenCart releases are not tested.
OpenCart 4
- Extensions > Installer > Upload
kv_login_security_2fa.ocmod.zip, then Install. - Extensions > Extensions > choose Modules, find Login Security: 2FA & Passkeys, click Install, then Edit.
- Choose the policies for administrators and customers, Save. The defaults are "optional" for both: nothing changes until someone turns it on or you make it required.
- Click My two-step sign-in (top right) and set up your own authenticator app or passkey first.
OpenCart 3
- Extensions > Installer > Upload
kv_login_security_2fa-oc3.ocmod.zip. - Extensions > Modifications > Refresh (the package's
install.xml has no modification rules; this only lists it). - Extensions > Extensions > Modules > Install, then Edit, then continue with step 3 above.
The panel is also under System > Login Security (2FA).
Updating
OpenCart 4: Extensions > Uninstall, Installer > Uninstall + Delete, upload the new package, Install, Extensions > Install. OpenCart 3: upload the new package over the old one and refresh the modifications. Authenticator apps, passkeys, recovery codes, the log, the settings and the licence state are kept: uninstalling never deletes them, so nobody has to set up again.
Uninstalling
Uninstall removes the events only: the second step stops at once. The data stays in the tables kv_ls_factor, kv_ls_passkey, kv_ls_log and kv_ls_meta (the encryption secret), so a later install picks it up again. To remove everything, delete those tables and the module_kv_login_security_2fa_* settings yourself.
Permissions
User groups (System > Users > User Groups) need Access to extension/kv_login_security_2fa/module/kv_login_security_2fa (OpenCart 3: extension/module/kv_login_security_2fa) to open the panel, and Modify to save settings, reset and unlock accounts. Every administrator manages their own two-step sign-in without any extra permission: Dashboard > My two-step sign-in (the Manage button on the profile page).
Configuration
Extensions > Modules > Login Security: 2FA & Passkeys > Overview & settings. The tiles on top show how many administrators and customers are protected, second steps passed and wrong codes in the last 7 days, and accounts locked right now.
| Setting | Default | What it does |
|---|
| Status | On | Off = no second step anywhere (administrators and customers). In the own-store edition the storefront step needs a valid licence or the 14-day trial; the admin step never depends on the licence. |
| Administrators: Policy | Optional | Off: no admin step. Optional: administrators can turn it on for themselves. Required for every administrator. Required for the groups below (user groups such as Administrator, Order Processing), optional for the others. |
| Administrators: Trusted devices | On | Lets administrators tick "Don't ask again on this device". Off = administrators are asked at every sign-in. |
| Customers: Policy | Optional | Same four choices; the groups are customer groups (for example Wholesale). |
| Authenticator apps | Always on | TOTP, RFC 6238, SHA-1, 6 digits, 30-second steps, one step of clock tolerance, every code works once. |
| Passkeys | On | Allows WebAuthn passkeys and security keys as the second step. Needs HTTPS. |
| Recovery codes | 10 | Fixed: 10 single-use codes per account, made at the first set-up, new ones on request. |
| Trusted device | 30 days | How long "Don't ask again on this device" lasts (0 - 365; 0 = the box is not offered). |
| Lockout | 5 wrong codes, 15 minutes | Wrong codes (or refused passkeys) within the lock time that lock the second step of that account (3 - 10 codes, 5 - 60 minutes). On top, 20 wrong codes in 24 hours lock it for the rest of that day. A recovery code still works while the step is locked (and ends the lock); recovery codes have their own limit of 10 tries per account and hour. |
| Keep the log | 90 days | Older log entries are deleted (7 - 730). |
| Licence key | empty | Own-store edition only: the key from your Kavio Labs account. Without a key the extension runs as a 14-day trial; after it (or with an invalid key) the customer step pauses and the admin keeps working. |
Tips
- Turn on your own authenticator app or passkey before you make the admin step required.
- B2B shops: make it required for the Wholesale group only; retail customers keep the optional step.
- Keep at least two administrators with access to the panel, so one can reset the other.
Usage
Setting it up (administrators)
Dashboard > My two-step sign-in (also the Manage button on your profile page, and the button on the panel).
- Authenticator app > Set up: scan the QR code (or type the key), type the 6-digit code, Turn on. Your 10 recovery codes are shown once: save them.
- Passkeys > Add a passkey: the browser asks for your fingerprint, face, screen lock or security key. Add a second passkey (another device or a USB key) as a backup.
- Changes need a fresh proof: removing a method, adding one to an account that already has one, and new recovery codes first show Confirm it is you: type a current code or recovery code, or use your passkey. The proof counts for 5 minutes (a sign-in step counts too).
- Recovery codes > New codes replaces all old codes. Trusted devices > Sign out all trusted devices makes every remembered device ask again.
Setting it up (customers)
My Account > Two-step sign-in: the same page inside your theme (authenticator app, passkeys, recovery codes, trusted devices).
Signing in
After the password, the second step appears: Use a passkey, or type the 6-digit code, or a recovery code (like ABCDE-23456). Tick "Don't ask again on this device" to skip the step on this device for the configured days.
- Administrators: the step stops every admin page until it is passed and then continues to the page that was asked for.
- Customers: the customer is signed out again until the step is passed (no account page, orders or saved addresses before that), then continues to the page they wanted (account, checkout).
- Required accounts without a method get the set-up page instead, then their recovery codes, then continue.
Recovery
- Lost phone: sign in with a recovery code, then set up the new phone under My two-step sign-in.
- Lost everything: another administrator with access to the panel resets the account (Administrators or Customers tab > Reset 2FA). The account then signs in with the password only and sets up again if it is required.
- Nobody can sign in to the admin: create an empty file
kv_login_security_2fa.off in OpenCart's storage folder (the panel shows where). The admin step is off while the file exists; delete it afterwards.
The admin tabs
- Overview & settings: tiles and all settings.
- Administrators: every admin user with group, methods (app, number of passkeys), recovery codes left, last second step and lock state; Unlock and Reset 2FA.
- Customers: the same for customers (enrolled customers first, search by name or e-mail, 50 per page).
- Security log: time, account, event, detail and IP address; filter by administrators or customers, event and name. Events: second step passed, trusted device, wrong code, passkey refused, locked, refused while locked, set-ups and removals, new recovery codes, recovery code used, reset and unlock (with the administrator who did it), sign-in by an administrator through "Login into Store".
Lockout
After the set number of wrong codes the second step of that account is locked for the lock time; 20 wrong codes in 24 hours lock it for the rest of that day. Wrong codes on the Confirm it is you box count too. A recovery code still works while the step is locked (and ends the lock); recovery codes have their own limit of 10 tries per account and hour. So a person who tries codes on someone else's account can lock the app code for a while, but never the owner's recovery codes. The lock ends by itself, or an administrator clicks Unlock.
Developer notes
Standards
- TOTP: RFC 6238 on HOTP (RFC 4226), SHA-1, 6 digits, 30 s, window -1..+1. A used step is claimed atomically (
UPDATE ... WHERE last_step < step), so a code works once even with two parallel requests. Tested with the RFC 6238 and RFC 4226 vectors. - WebAuthn Level 2: ES256 and RS256 (EdDSA refused), attestation
none and packed self-attestation, origin and RP ID checks, user presence, backup flags, signature counter. CBOR and COSE parsing in plain PHP, signatures verified with OpenSSL. Challenges are single use and expire after 5 minutes. - Secrets: TOTP secrets are encrypted with AES-256-GCM; recovery codes and trust cookies use HMAC-SHA-256 with keys derived from a random secret in
kv_ls_meta. - The client IP in the log is
REMOTE_ADDR only (forwarded headers are never trusted).
Sign-in flow
- Admin: event
admin/controller/*/before (first call = the page route). A signed-in user who has not passed is sent to the verify or set-up page; the pass is bound to the session's user_token (session plus database mark). OpenCart 4.1's own e-mail device check (config_user_2fa) is marked as authorised after our step. - Storefront: event
catalog/controller/*/before. Only the extension's own verify, set-up and recovery-code routes are not gated (its Two-step sign-in page is). A signed-in customer who needs the step is put on hold (signed out, data kept in the session for 15 minutes) and sent to the verify or set-up page; the step signs the customer in again (OpenCart 4: new customer_token). On OpenCart 4 the JSON answer of account/login.login is rewritten so the login form goes straight to the step. api/* routes are never gated. - "Login into Store": the one-time token (OpenCart 4
customer_token table, OpenCart 3 customer.token) is checked before OpenCart uses it; that sign-in skips the step and is logged.
Data
| Table | Contents |
|---|
kv_ls_factor | One row per account (subject u = admin user, c = customer): encrypted TOTP secret, last step, recovery code hashes, passkey user handle, trust version, failure counter, lock time |
kv_ls_passkey | Credential id, public key (PEM), algorithm, signature counter, RP ID, transports, name |
kv_ls_log | Security log |
kv_ls_meta | Installation secret |
Events
OpenCart 4: admin/controller/*/before, admin/controller/common/header/before (own-store edition: licence check), admin/view/common/column_left/before (menu), admin/view/user/profile/after, admin/view/user/user_form/after, catalog/controller/*/before, catalog/view/account/account/after, catalog/controller/account/login.login/after. OpenCart 3: the same without the login event (common/profile for the profile page). No OCMOD rules (the OpenCart 3 install.xml only names the package), no core edits. On an error inside a gate the request fails closed for accounts that have or need a second step (signed out, "try again" page).
Endpoints
Admin and storefront pages post to themselves with a form token (kv_ls_t) and a kv_ls action; passkey options and answers are JSON (native fetch, no library, the same vanilla script on OpenCart 4 and 3).
FAQ
Does it work for customers too?
Yes. Customers manage it under My Account; you can make it required for chosen customer groups (for example Wholesale).
Which apps work?
Every authenticator app with 6-digit TOTP codes: Google Authenticator, Microsoft Authenticator, 1Password, Authy, Bitwarden, KeePass and others.
Can passkeys replace the password?
Not in this version: the passkey is the second step after the password.
Do passkeys work without HTTPS?
No, browsers allow passkeys only on HTTPS (and localhost). Authenticator apps work on any connection.
What if an administrator loses the phone?
A recovery code, a reset by another administrator, or the emergency file described in Usage.
Does a lock shut people out?
No. It locks only the app codes and passkeys of the second step for the lock time; a recovery code still works (10 tries per hour) and ends the lock, or an administrator unlocks the account.
Are codes sent by e-mail?
No. The extension sends no e-mail at all.
OpenCart 4.1 has its own e-mail device check. Do I get both?
For administrators, a device that passed our step is marked as authorised for OpenCart's check too. You can switch OpenCart's own customer check off when you use this extension.
I also use Security & Anti-Spam. Administrators who use (or must use) its two-step sign-in are asked by Security & Anti-Spam only; all other administrators are asked by this extension. Customers are protected by this extension.
Does it change core files?
No. Events only; the OpenCart 3 package has an install.xml without modification rules.
What does uninstall delete?
Only the events. Methods, passkeys, the log and settings stay, so an update never locks anyone out.
Where is the encryption key?
In the extension's own kv_ls_meta table: a random secret made at install and kept on uninstall. Back up that table together with the others.
Is any data sent out?
No. Codes and passkeys are checked on your server. The own-store edition checks its licence key with Kavio Labs (key, store address, OpenCart version).