An admin login page that anyone can reach gets visitors who are not your staff. Bots try admin with common passwords, a former contractor still has a bookmark, a password leaked with some other site gets tried here. Most of these attempts fail and leave no mark anyone looks at. The one that succeeds looks like any other admin session.
Magento protects the login form, and it does that job well. What it doesn't do is tell the people who look after the store.
What Magento does on its own
The settings are under Stores > Settings > Configuration > Advanced > Admin > Security:
- Maximum Login Failures to Lockout Account, 6 by default. After that many wrong passwords within the lockout time, the account is locked.
- Lockout Time (minutes), 30 by default. How long the lock lasts.
- Admin Account Sharing, No by default. One admin account can't be signed in from two places at once: a new sign-in ends the older session, and both sessions see a message about it.
Accounts with a lock are listed under System > Permissions > Locked Users, where you can unlock them. With Admin Account Sharing set to Yes, the admin's footer has an Account Activity link: it lists your own account's open sessions, with their IP address and start time, and can log out the others.
Magento 2.4 also asks for a second factor after the password, with Google Authenticator, Duo or a security key, through its Two-Factor Authentication module. Keep it on.
What none of this tells you
The lockout works silently. When someone enters six wrong passwords for your admin account within half an hour, the account is locked, and the person who owns it finds out only when they try to sign in. Nobody else finds out at all. The Locked Users grid shows which accounts have a lock, not who tried them, from where, or when.
Account Activity shows only your own sessions, and only while you are looking. Magento keeps each admin's last sign-in time, but Magento Open Source has no log of sign-ins and failed attempts to read in the admin: the Action Logs report is in Adobe Commerce only.
And the error message doesn't help. Magento gives the same reason for a wrong password, a username that doesn't exist, an inactive account and a locked one: The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later. That is right for the login form, where telling an attacker which usernames exist would help them. So the reason rarely tells you much. The username often does.
Two alerts worth having
Multichannel Store Notifications has a monitoring module with two events for the admin login. Both are published as soon as they happen, not by a check every few minutes.
Admin login failed is sent each time Magento refuses a username and password on the admin login page. A wrong two-factor code after a correct password is not reported by it. The message has the username and Magento's reason, and, if you ask for it, the IP address. Other reasons than the one above show up too, such as Incorrect CAPTCHA. or More permissions are needed to access this. for a user without a role.
Admin logged in is sent when an admin signs in, with two fields that say whether the sign-in is unusual:
- From a new address is Yes when this admin has not signed in from this IP address in the past year.
- From a new device is Yes when this admin has not signed in from this browser in the past year.
With Magento's own login form, the event is sent once Magento accepts the password, before the second factor is asked for. So a sign-in from a new device that wasn't you means someone has the password, even if two-factor authentication stopped them. Change the password then.
Set them up
- Make a topic, such as Store health, and subscribe the people who manage the admin accounts. A chat such as Telegram or Slack works well, because a sign-in is worth reading at once. See Topics and Subscriptions.
- Open Arlanix > Notifications > Rules and click Add rule.
- Name it Failed sign-ins as admin. Choose the Event Admin login failed and the Topic Store health. Add the condition Username is admin and set the Severity to Error. In Subject, enter
Failed admin sign-in as {admin.username}: {admin.reason}. - Click the arrow next to Save, then Save & Close.
- Add a second rule, Sign-ins from a new device, for the Event Admin logged in and the same topic. Add the condition From a new device is Yes. In Subject, enter
{admin.username} signed in from a new device, and in BodyFrom {admin.ip}, {admin.user_agent}.Save it the same way.
Both rules are in Rule examples, and Rules explains each field.
The first rule is built on one guess: many stores have no admin user called admin, so whoever tries it is guessing. If your store does have one, rename it, and keep the rule. You can add other names that attackers try, such as administrator or test: add a condition for each and change ALL to ANY. A rule with no condition at all sends every typo your staff make, which teaches everyone to ignore it.
The second rule's messages have the severity Info unless you change it, so they reach only subscriptions that take info messages. Set the rule's Severity to Warning if your subscriptions take only warnings and errors.
When a bot tries the same username many times in a few minutes, the messages that wait together go out as one digest, and a repeated message appears once with the number of times it came.
What counts as new
To know whether an address or a device is new, the store remembers the ones each admin signed in from, for a year after the last sign-in from each. This history is kept as hashes made with the store's own encryption key, not as addresses. The device is the browser, recognized by a cookie it keeps.
A few things follow from that:
- The first sign-in after installing is from a new address and a new device for every admin. Expect one message for each admin as they first sign in.
- A private window, another browser or cleared cookies count as a new device. An admin who signs in from a new private window each time gets a message each time.
- New addresses are common. Home internet, mobile data and a VPN change the address often, so the new-address condition is noisy for most teams. The new-device one is the better default.
- Behind a proxy, such as a load balancer, Cloudflare or Varnish, the store may see the proxy's address for every sign-in. Then every failed sign-in shows the same address, and an address is never new after the first time. Behind a proxy in the developer docs says how to pass the visitor's address to Magento.
The IP address and the browser are personal data. A rule sends them only when its message names them, as the second rule's body does, and the Message Log then keeps them with the message. Admin sign-ins in the manual has the details.
Looking or being told
| Magento alone | Multichannel Store Notifications | |
|---|---|---|
| Someone guesses at a username | Locked after 6 wrong passwords in 30 minutes, if the username exists; nobody else is told | Admin login failed, with the username and the reason |
| An account is locked | Listed in Locked Users | Each failure before it, as it happens |
| An admin signs in from a new browser | Not told apart from other sign-ins | Admin logged in with From a new device Yes |
| Past sign-ins | Each admin's last sign-in time; no log in Open Source | The Message Log keeps the messages your rules sent, 30 days by default |
| Where you hear of it | On the admin screen, if at all | Email, Slack, Telegram, Discord, Teams, WhatsApp or a webhook |
| Cost | Built into Magento | An extension from Adobe Commerce Marketplace |
Multichannel Store Notifications runs on Magento Open Source or Adobe Commerce 2.4.7 or later, with PHP 8.1 to 8.5. A sign-in publishes its message at once, and the store's queue consumer, which cron usually starts, usually sends it within a minute. 7 Alerts Every Magento Store Should Set Up lists the other alerts worth having, and Magento Cron Not Running? explains how to know that delivery keeps working.