Lynbro Login Guard

By lynbro

0+ active installationsVersion 0.3.1

Move wp-login.php to an address you choose, limit failed sign-ins and add two-factor. All on your own server, with a way back in.

Description

Three things guard a WordPress sign-in page, and this plugin does all three on
your own server: it moves the page to an address of your choosing, it makes
failed sign-ins cost time, and it can ask for a code from an authenticator app
after the password.

There is no account to create, no API key to paste, nothing to pay for and
nothing sent anywhere. Every automatic decision is written down in plain
language, and every one of them can be undone in a click.

Source code and issue tracker on GitHub:
https://github.com/andrey-tut/lynbro-login-guard

You cannot lock yourself out

This is the part that usually goes wrong, so it is the part built first. Plugins
that move the sign-in page are famous for one support thread: “I changed the
address and now I cannot get in.”
There are three ways back here, and the
plugin tells you about them before you need them.

  1. The address is shown, in full, on the plugin’s own screen — and e-mailed to
    your site’s administration address, from your own site, whenever it changes.
  2. WP-CLI: wp lynbro-login-guard url prints it, wp lynbro-login-guard off
    puts the page back where WordPress had it.
  3. One line in wp-config.php switches every guard in the plugin off without
    deleting a single setting:
    define( ‘LYNBRO_LOGIN_GUARD_DISABLE’, true );

Deactivating the plugin has the same effect. Nothing here can leave you outside
your own site.

Moving the sign-in page

Pick an address and wp-login.php stops showing the form. Visitors who ask for
the old one get your theme’s own 404 page, or the front page, or an address you
choose.

Before the address is saved it is checked against your site: a page, post,
category or tag already living there would swallow the sign-in page and leave
you with a 404, which is exactly what people complain about with other plugins.
If the address will not work, the plugin says why and keeps the one that was
working.

Things that must keep working, keep working: unlocking a password-protected
post, WordPress recovery mode after a fatal error, admin-ajax, admin-post, cron,
WP-CLI and the REST API are all left alone. So is the sign-in page itself for
anybody who is already signed in — locking somebody out of their own log-out
button helps nobody.

Be clear-eyed about what this buys you: a moved address stops the automated
traffic that only ever knocks on wp-login.php. It is one layer, not a lock.
The limit below is what actually stops somebody guessing passwords.

Limiting failed sign-ins

Two counters run side by side, because they answer different questions. One is
keyed on the address and notices a single machine working through passwords.
The other is keyed on the username and notices one account being tried from a
hundred addresses at once — which the first cannot see at all.

Past the limit, that address or that username waits. A repeat offender waits
longer each time, up to a ceiling you set. Every lockout ends by itself: there
is no permanent ban here and there is not going to be one.

Getting the password right clears the counter, so somebody who mistyped twice
and then got in is not one slip away from a lockout tomorrow. Addresses you
list are never limited at all — put your office in there.

Two-factor sign-in

Any authenticator app. The password is checked by WordPress exactly as before;
only then does a second screen ask for six digits. Ten single-use recovery codes
are made when you switch it on, and an administrator can switch two-factor off
for somebody who has lost both their phone and their codes.

The QR code is drawn by this plugin, on your server, and put straight into the
page. Most plugins hand your shared secret to an outside chart service to get a
picture back. That secret is the one value that must never leave your site.

The smaller things that stop a sign-in page answering questions

  • Say the same thing whether the username or the password was wrong, so the form
    cannot be used to find out which accounts exist. The lost-password form stops
    confirming addresses too.
  • Ignore /?author=1, which otherwise hands over a username.
  • Optionally keep the REST API from listing users to strangers, and optionally
    switch XML-RPC off. Both are off by default, because both break real sites
    when switched on without thinking.
  • Optionally refuse a list of usernames outright — and if one of them turns out
    to belong to a real administrator, it is let through anyway, because that is
    almost certainly you.

The journal

Every refusal, lockout and rejected code is recorded with the reason in a
sentence: not “blocked”, but “8 failed sign-ins from this address in 15
minutes, so it is held out for 20 minutes”
. One click lets that address back in
and forgets the failures that caused it. Another adds it to the list that is
never limited. The whole journal exports to CSV, and it is deleted after however
many days you choose.

No limits

No caps, no quotas, no counting, nothing switched off after a number. Every
feature here runs on your server and costs us nothing, so it is free, for every
site, for as long as you have the plugin.

External Services

This plugin’s own features do not connect to any external service. Nothing is sent anywhere,
and no code, font, script or image is loaded from another server.

Two things are worth naming because they look like exceptions and are not:

  • The QR code for setting up two-factor sign-in is generated by this plugin
    in PHP and written into the page as SVG. It is not fetched from a chart
    service, so the shared secret never leaves your site.
  • The e-mail telling you that the sign-in address has changed is sent by your
    own WordPress installation, through whatever mail setup your site already
    uses, to the administration address in Settings → General. It goes nowhere
    else, and it can be switched off.

WordPress.org plugin directory (the shared Lynbro “Our plugins” screen).
Apart from the above, one request goes to WordPress.org, from every Lynbro plugin
alike: when an administrator who may install plugins opens Lynbro → Our plugins,
the screen asks the WordPress.org Plugin Directory API
(https://api.wordpress.org/plugins/info/1.2/) which Lynbro plugins are listed,
through WordPress core’s own plugins_api() — the same call the Plugins → Add New
screen makes.

  • What is sent: the query (plugins by the author “lynbro”), plus what WordPress
    core adds to every request to WordPress.org: your WordPress version, the admin
    language and, in the User-Agent, your site address. Nothing about your visitors,
    users or content.
  • When: only on that screen, at most once a day (the answer is cached for a day;
    after a failed request, an hour). No other screen and no visitor request triggers it.
  • Installing a suggested plugin uses WordPress core’s own installer, which downloads
    the plugin from downloads.wordpress.org — only when you click “Install now”.
  • WordPress.org Terms of Service ·
    Privacy Policy

Privacy

Everything the plugin records is stored in two tables in your own database and
never leaves your site.

The journal holds, for each event: the time, what happened, the username that
was tried, the visitor’s IP address, the browser identification string, and the
reason in plain language. Storing the IP address can be switched off, at the
cost of no longer being able to see where attempts came from. Entries are
deleted automatically after the number of days you set — 30 by default — and you
can empty the journal yourself at any time.

For accounts using two-factor sign-in, the plugin stores the shared secret and
the hashes of the unused recovery codes against that account. The recovery codes
themselves are shown once and never stored, so nobody can read them back.

Deleting the plugin removes both tables, every setting, and all two-factor data
from every account.

Installation

  1. Install and activate the plugin.
  2. Open Lynbro → Login Guard. Failed sign-ins are already being limited;
    nothing else has changed yet.
  3. On the Settings tab, tick “Move the sign-in page” and choose an address. The
    new address is shown on the Overview tab and e-mailed to you.
  4. Each person who wants two-factor sign-in switches it on from their own
    profile.

FAQ

What happens if I forget the new sign-in address?

Three ways back. It is e-mailed to your site’s administration address whenever
it changes. wp lynbro-login-guard url prints it. And adding
define( ‘LYNBRO_LOGIN_GUARD_DISABLE’, true ); to wp-config.php puts the page
back at wp-login.php without deleting anything — take the line out again when
you are back in. Deactivating the plugin does the same.

Does moving the sign-in page actually make my site safer?

It stops the automated traffic, which is most of it, and that alone quietens
your logs and your server. It is not a lock: anybody who learns the address can
still knock. The attempt limit and two-factor sign-in are what stop somebody who
is actually trying.

My custom login address gives a 404. Why?

Almost always because something else already lives at that address. The plugin
checks pages, posts, categories and tags before saving and refuses an address
that collides — so if it happens anyway, look for a rewrite rule from another
plugin, or a rule on the web server itself, that claims the path first.

Does it work behind a page cache or a CDN?

Yes, and more carefully than the short answer suggests. The sign-in page is sent
with the headers every common cache understands — including the one nginx honours
when it has been told to ignore the others, which is the configuration a good deal
of shared hosting ships with. Some caches also keep a list of addresses they never
store, and every such list has wp-login.php on it; none of them can have yours,
because you chose it. So the plugin hands your address to any cache that offers a
way to be told.

Will it lock me out if I get my own password wrong?

The lockout is temporary and always ends. You can also list your own address so
it is never limited, lift any lockout from the journal in a click, or run
wp lynbro-login-guard unblock

<

address>.

Does two-factor work with my authenticator app?

Any app that does standard time-based codes: six digits, thirty seconds. Scan
the QR code or type the key in by hand.

What if I lose my phone?

Use one of the ten recovery codes you were shown when you switched it on. If
those are gone too, any administrator can switch two-factor off for your account
from your profile screen, and it is recorded in the journal with their name.

Can I restrict sign-in by country?

Only if something in front of WordPress already works the country out —
Cloudflare, a CDN, mod_geoip. There is no address database in this plugin and no
lookup service behind it, so if your server does not provide that information
the setting says so instead of quietly doing nothing. Worth knowing: a country
header is only trustworthy when something in front of WordPress sets it and
strips whatever the visitor sent.

Does it count sign-ins that do not go through the sign-in form?

Yes, and that is deliberate. Anything that authenticates a person — a REST
endpoint, an app, another plugin’s own login form — tells WordPress when it
fails, and this plugin listens for that. So an account being guessed at through
an API is limited exactly like one being guessed at through the form, even
though moving the sign-in page does nothing for that route.

One thing to expect from it: a plugin that guards an API route usually keeps its
own counter as well. Two counters running side by side is not double blocking —
they are watching two different doors — but if you are ever surprised by a
lockout, the journal names which one acted and why.

My site is behind Cloudflare (or a load balancer). Will one bot lock everybody out?

Not once you say so. Behind Cloudflare every visitor reaches your server from a
Cloudflare address, so a limit keyed on the address would treat the whole world
as one visitor. The overview screen notices this and tells you. Under Settings →
“Where a visitor’s address comes from” choose Cloudflare: the plugin then reads
the CF-Connecting-IP header, but only when the request really came from
Cloudflare’s published network — a forged header sent straight to your server is
ignored. For your own proxy or load balancer, name its address and the header it
sets; the header is believed only from that machine.

I use WPS Hide Login. How do I switch?

Install this plugin and open Login Guard. It finds the address WPS Hide Login is
using and offers to keep it, in one click, so nobody who signs in notices the
change. Then deactivate WPS Hide Login — two plugins moving the same page take
turns answering it, and the overview warns you while both are on.

Can visitors still see the new address in the “Log in” link?

Only if you let them. The Meta widget, the Log in/out block and themes that call
wp_loginout() link to the address you chose. Settings → “Take the Log in and
Register links off public pages for visitors” removes those links for anybody
not signed in. It is off by default, because some sites’ visitors sign in from a
page — a shop’s My account page, “log in to reply” under comments.

Does the WooCommerce mobile app still work?

Yes. The app signs in through the REST API with an application password, and the
REST API is left alone; only the browser sign-in page moves. Failed sign-ins
through the API are still counted.

Does it work with Lynbro Antispam Guard?

Yes, and they do not repeat each other’s work. Antispam Guard scores what gets
posted to the sign-in form; Login Guard handles the address, the attempt limits
and two-factor, and hands Antispam Guard what it knows about failed sign-ins from
each address so its log names the same reason.

Screenshots

Changelog

0.3.1

  • Journal: the event filter has a label for screen readers (axe “select-name”).

0.3.0

  • Multisite: network-activate Login Guard and one set of settings protects every site of the network from that moment — including sites created later — without writing anything into each site. Network Admin → Settings → Login Guard holds them. A network administrator can give one site its own settings and put it back on the network’s; site administrators cannot switch the guard off for their own site.
  • The network’s login address is checked against every site that follows it: an address a page, post, category or tag already uses on any of them is refused, naming the sites.
  • Moving over from WPS Hide Login on a network takes its network-wide address into the network settings.
  • Settings are now read per site within one request, so code that switches between sites never sees another site’s settings.

0.2.4

  • Internal: the 404 for the old address no longer defines WP_USE_THEMES (it uses the wp_using_themes filter), and the “back to wp-login.php” address comes from the plugin’s one login-address function.

0.2.3

  • With the sign-in page moved, wp-login.php?action=entered_recovery_mode (and enter_recovery_mode without its token) no longer shows the sign-in form, and with it the new address, to anybody who asks. That screen now opens only for the browser that just followed a valid recovery-mode link.
  • The recovery-mode link in WordPress’s “your site is having a technical issue” email works again with the sign-in page moved: it stays at wp-login.php, where WordPress handles it before any plugin loads. Before, it pointed at the new address and ended on a 404.
  • An old recovery link opened at the new address shows the sign-in form instead of a 404.

0.2.2

  • Readme: External Services now names the one WordPress.org request the shared “Our plugins” screen makes — what is sent, when, and the WordPress.org terms and privacy policy.
  • The plugin names and descriptions on “Our plugins” and in the suggestions are translatable.
  • Links on Lynbro screens use the darker brand green, which meets WCAG AA contrast on the admin background.

0.2.1

  • Shared Lynbro admin 1.1.0: after two weeks of use and a first success (for example settings saved), this plugin’s own screen asks once, politely and without stars, whether it is doing its job. Answers are per user: “Maybe later” or “Don’t ask again”, and only one Lynbro plugin asks in any 30 days.
  • A small “Suggested for this site” block under the plugin’s main screen lists Lynbro plugins that fit what the site already uses (WooCommerce, forms, a Danish setup …), with the reason. It can be hidden; nothing installs on its own and nothing is sent anywhere.
  • Tab labels on Lynbro screens meet WCAG AA contrast.
  • Lynbro admin screens now read the plugin’s bundled translations (languages/) when WordPress has no language pack for it, so a Danish admin sees Danish instead of English.

0.2.0

  • New: Cloudflare and reverse-proxy support. Choose where a visitor’s address comes from; a forwarded header is believed only from Cloudflare’s own network or from the proxy you name, never on its word. The overview warns when the site looks like it sits behind a proxy the settings do not know about.
  • New: one-click move from WPS Hide Login — keeps the address and the /wp-admin/ behaviour you already have, and warns while both plugins are active.
  • New: optional removal of the “Log in” and “Register” links from public pages for visitors, so the new address is not on show.
  • Fix: the settings screen now shows “Settings saved” and, when a value is refused, the reason — for example a sign-in address that a page already uses. Before, the refusal happened silently.
  • Change: database queries name their tables through %i placeholders, so WordPress 6.2 is now the minimum.
  • Change: an account whose role must use two-factor sign-in can no longer switch it off on its own profile. Another administrator can still reset it for a lost phone.

0.1.1

  • Fix: with the sign-in address hidden, /wp-admin/ for a signed-out visitor returned a 500 instead of the 404 (the admin bar asked for an admin screen that does not exist).

0.1.0

  • First release.
  • Move the sign-in page to an address you choose, with the address validated
    against your own content before it is saved.
  • Three ways back in: the address on screen and by e-mail, WP-CLI, and a
    wp-config.php constant that switches every guard off.
  • Failed sign-ins limited by address and by username, with escalating but always
    finite lockouts.
  • Two-factor sign-in with any authenticator app, recovery codes, and a QR code
    drawn on your own server.
  • Uniform sign-in errors, no account enumeration through the lost-password form
    or /?author=1, optional REST and XML-RPC restrictions.
  • Journal of every decision with the reason, one-click undo, CSV export.
  • WP-CLI commands, and a bridge to Lynbro Anti-Spam that avoids duplicate work.