Nahnu Login Shield

By Jaime Alnassim

30+ active installationsVersion 1.0.19

Hyperfocused login security. CAPTCHA, brute-force lockout, geo-blocking, 2FA, honeypot, and edge WAF — all from one screen. 100% free.

Description

Nahnu Login Shield protects every WordPress login entry point: the login form, WooCommerce My Account, XML-RPC, the REST API and your form plugins. It is a login security plugin, not a general security suite.

No subscription. No license key. No upsell. Everything is free.

Brute-force lockout

  • Attempt limit, time window and lockout duration, with escalating lockouts (default 24 h) for repeat offenders.
  • Per-username lockout stops distributed botnets trying one username from many IPs.
  • Honeypot usernames (admin, root, test…) lock the IP on the first attempt.
  • IP blocklist and allowlist with CIDR ranges (IPv4 and IPv6), and one-click unlock.

Early blocking

An optional must-use plugin turns locked-out IPs away before WordPress loads. It is off by default and never installed automatically: click “Install early-block mu-plugin” on the General tab, and “Remove” to delete it again.

CAPTCHA / verification providers

One provider site-wide, shown on every protected form: OOPSpam (with VPN, data-centre and disposable-email blocking), reCAPTCHA v2 and v3, hCaptcha, Cloudflare Turnstile (managed or invisible), Friendly Captcha, Cap, mCaptcha and ALTCHA, or none.

Two-factor authentication

  • Every user in the roles you choose gets a one-time code after their password. Email codes are always on; users can add an authenticator app (TOTP) or a passkey.
  • Backup codes, admin reset for lost phones, and an emergency switch: define( 'NAHNLS_DISABLE_2FA', true );.
  • Works on wp-login.php and inside WooCommerce My Account.

Passwordless sign-in

  • Passkeys (WebAuthn): Touch ID, Windows Hello, phones and security keys, with browser autofill. Built-in verifier, no external service.
  • Magic links: one-time email login links, hashed at rest and rate-limited, with a per-user opt-out.

White-label emails

2FA codes, magic links and signup confirmations use your sender name, logo, colours and footer. Subject, heading and intro are editable, with a preview and test send.

Access control

  • Restrict roles to IP addresses or CIDR ranges.
  • Login and logout redirects per role.
  • XML-RPC kill switch.
  • Signup email verification with pruning of unconfirmed accounts.
  • Security checklist with a score and one-click fixes.

Geo-fencing

Reads the visitor country from CDN headers (Cloudflare, Bunny.net, CloudFront, Vercel, Fastly/Akamai) with no API quota, falling back to freeipapi.com or ipinfo.io with caching.

Edge blocking: Bunny.net and Cloudflare

  • Push locked-out and honeypot IPs to the Bunny.net or Cloudflare WAF so attackers are stopped at the CDN edge, with automatic expiry and a block log with one-click unblock.
  • Bunny Shield: one-click login rate limit (covers wp-login.php, xmlrpc.php and your custom login path), blocked IPs on a Shield access list, “Block network” for attacker ASNs, and warnings for learning mode or log-only WAF. Works with Nahnu Cache Connector for Bunny.net.
  • Cloudflare WAF: one-click login rate limit on every plan (fixed limits on Free, your own on Pro and up), added next to your existing rules; blocked IPs with Unblock; “Block network” on every plan.

More protection

  • JavaScript presence check blocks headless bots before CAPTCHA or lockout checks run.
  • Custom login URL renames /wp-login.php; the old URL returns 404 or redirects.
  • REST API: block user enumeration, apply lockouts to REST authentication, optionally disable Application Passwords.
  • Sessions: idle timeout with a warning, and force-logout of all sessions.
  • Notifications: login emails, admin-login alerts, new-country alerts and a weekly security digest.

WooCommerce My Account

All protections extend to the My Account login, registration, lost-password, checkout and order-tracking forms, each with its own toggle. Customers get a Login & security tab to manage passkeys, 2FA and sign-in options without seeing wp-admin. The same panel is available anywhere with the [nahnls_account_security] shortcode.

Form plugin integrations

Bricks Builder forms (per form), SureForms (all forms or the ones you pick) and the WordPress comment form, each with its own toggle. Anything else can integrate through the developer API: template tags, shortcodes, actions and filters, REST routes under nahnls/v1 and a JavaScript API (see docs/API.md).

Event log and analytics

  • Search, filter by event type and date, and export to CSV. Every event shows the form or endpoint it came from.
  • Daily activity, time-of-day heatmap, event breakdown, and top attacking IPs and targeted usernames.
  • Configurable retention and row cap. All data stays on your site.

MainWP extension

A separate companion extension shows lockouts, edge blocks, recent events and settings across all your MainWP child sites.

Privacy

IP addresses and usernames are stored in a local database table for the event log, with configurable retention. No data is sent to any Nahnu server. Third-party services you enable receive only what they need (see below). Deleting the plugin removes all stored data.

External services

Nahnu Login Shield works fully offline by default. Each service below is contacted only when the site administrator explicitly selects or configures it in the plugin settings. No data is ever sent to a Nahnu server.

  • Google reCAPTCHA (v2 / v3) — Used as the CAPTCHA provider when selected on the Widget tab. The visitor’s browser loads the widget script from https://www.google.com/recaptcha/api.js on protected forms, and Google receives the visitor’s IP address and browser information per its own policy. On every form submit the plugin sends the reCAPTCHA response token together with your reCAPTCHA secret key server-to-server to https://www.google.com/recaptcha/api/siteverify. Terms of Service · Privacy Policy
  • hCaptcha — Used as the CAPTCHA provider when selected. The visitor’s browser loads the widget from https://js.hcaptcha.com/1/api.js on protected forms (hCaptcha receives the visitor’s IP and browser data). On form submit the plugin sends the hCaptcha response token and your secret key server-to-server to https://api.hcaptcha.com/siteverify. Terms of Service · Privacy Policy
  • Cloudflare Turnstile — Used as the CAPTCHA provider when selected (managed or invisible mode). The visitor’s browser loads the widget from https://challenges.cloudflare.com/turnstile/v0/api.js on protected forms (Cloudflare receives the visitor’s IP and browser data). On form submit the plugin sends the Turnstile token and your secret key server-to-server to https://challenges.cloudflare.com/turnstile/v0/siteverify. Terms of Service · Privacy Policy
  • Friendly Captcha — Used as the CAPTCHA provider when selected. The widget script itself is bundled with the plugin (no CDN), but the visitor’s browser fetches a proof-of-work puzzle from api.friendlycaptcha.com while the form is displayed (Friendly Captcha receives the visitor’s IP address). On form submit the plugin sends the solved puzzle token (frc-captcha-solution) plus your site key and your Friendly Captcha API key server-to-server to https://global.frcapi.com/api/v2/captcha/siteverify. Terms of Service · Privacy Policy
  • OOPSpam Anti-Spam — Used as the verification provider when selected; requires the separate OOPSpam Anti-Spam plugin with its own API key. On login/registration submit (and optionally at widget render) the plugin calls the OOPSpam plugin, which sends the visitor’s IP address and the submitted username/email, together with your OOPSpam API key, to the OOPSpam API to obtain a spam/VPN/data-centre score. Terms of Service · Privacy Policy
  • Bunny.net API (https://api.bunny.net) — Used only when the Bunny WAF edge-blocking integration is enabled on the Edge Blocking tab. When a lockout or honeypot event fires, the plugin sends the blocked IP address, an expiry timestamp and a short note, authenticated with your Bunny API key, to the Bunny WAF IP-block endpoint for your pull zone. The “Test connection” button reads your pull zone details with the same key. Terms of Service · Privacy Policy
  • Bunny Shield API (https://api.bunny.net/shield/...) — Used only when a Bunny connection is configured on the Edge Blocking tab (your own key, or the one from the Nahnu Cache Connector for Bunny.net plugin when you choose to reuse it). The Edge Blocking tab reads your Shield zone’s plan and status, and when you click “Turn off learning mode” or “Switch the WAF to Block” it changes that one setting on your Shield zone. When you click “Create rule”, the plugin creates (and later updates or removes) one rate-limit rule containing your login paths and the limits you chose. When a lockout is pushed to Bunny and the pull zone has Shield, it creates a Shield access list with the first IP and sends it the IP addresses of locked-out visitors, removing them when the lockout expires or you unlock them. When you block a network, it sends the AS number to a second access list. All requests are authenticated with your Bunny API key. Terms of Service · Privacy Policy
  • Team Cymru IP-to-ASN mapping (DNS: origin.asn.cymru.com, origin6.asn.cymru.com, asn.cymru.com) — Used only when an administrator clicks “Block network…” on a locked-out IP. The plugin makes a DNS lookup containing that IP address (reversed, as DNS requires) to find the network (AS number and name) it belongs to, and shows it for confirmation before anything is blocked. No other data is sent. Service description · Privacy Policy
  • Cloudflare API (https://api.cloudflare.com/client/v4) — Used only when the Cloudflare WAF edge-blocking integration is enabled. When a lockout or honeypot event fires, the plugin creates an IP access rule containing the blocked IP address and a note, authenticated with your Cloudflare API token; a scheduled task later deletes that rule when the block expires (or when you unlock the IP), and the “Test connection” button verifies the token. On the Cloudflare WAF tab, the plugin reads the zone’s name and plan, and, only when you use them, creates, updates or deletes one rate limiting rule (the login paths and the limits) and IP access rules for the network AS numbers you block. Terms of Service · Privacy Policy
  • freeipapi.com — Geo-lookup fallback, used only when geo-blocking is enabled and “freeipapi” is selected as the API source and no CDN country header is present. On a login attempt the plugin sends the visitor’s IP address (and your optional API key as a bearer token) to https://free.freeipapi.com/api/json/{ip} to learn its country code; results are cached locally per IP. Terms of Use · Privacy Policy
  • ipinfo.io — Geo-lookup fallback, used only when geo-blocking is enabled and “ipinfo” is selected as the API source. On a login attempt the plugin sends the visitor’s IP address (and your optional API token) to https://api.ipinfo.io/lite/{ip} to learn its country code; results are cached locally per IP. Terms of Service · Privacy Policy
  • Self-hosted Cap and mCaptcha instances — If you select the Cap or mCaptcha provider you must enter the URL of an instance you host. The visitor’s browser loads that instance’s widget script, and on form submit the plugin sends the challenge token and your secret key server-to-server to {your-instance}/siteverify (Cap) or {your-instance}/api/v1/pow/siteverify (mCaptcha). No third party is involved unless you point the URL at one; see the Cap and mCaptcha documentation for their respective terms.
  • ALTCHA — If selected, verification is handled locally by the separately installed ALTCHA plugin; this plugin makes no external request for it.

Country flags shown in the admin log are SVG files bundled with the plugin (assets/img/flags/); no flag CDN or other external image service is used.

Bundled third-party libraries

No scripts are loaded from a CDN. These libraries ship inside the plugin (assets/vendor/ unless noted otherwise):

  • Chart.js 4.4.1 — MIT License, https://www.chartjs.org. Used on the Analytics admin tab.
  • Friendly Captcha widget (friendly-challenge 0.9.18) — MIT License, https://github.com/FriendlyCaptcha/friendly-challenge. Used only when Friendly Captcha is the selected CAPTCHA provider.
  • flag-icons (country flag SVGs in assets/img/flags/) — MIT License, https://github.com/lipis/flag-icons. Displayed in the admin event log; loaded from the plugin folder, never from a CDN.

Installation

  1. Upload the nahnu-login-shield folder to /wp-content/plugins/.
  2. Activate through Plugins in the WordPress admin.
  3. Go to Settings > Login Shield to configure.

Quick start:

  1. On the Widget tab, choose a CAPTCHA provider (or leave it as None to use lockout only).
  2. On the Lockout tab, review the attempt thresholds.
  3. On the Geo tab, enable geo-blocking and select blocked countries if needed.
  4. On the Integrations tab, enable protections for WooCommerce My Account, Bricks Builder forms, SureForms and WordPress comments as needed.
  5. On the Edge Blocking tab, connect your Bunny.net or Cloudflare account to push blocks to the edge.

To use OOPSpam, install and activate the OOPSpam Anti-Spam plugin and enter your API key there first. Nahnu Login Shield detects it automatically.

FAQ

Do I need OOPSpam installed?

No. OOPSpam is one of seven CAPTCHA provider options. All other providers and all other features work independently.

Does this plugin slow down my site?

No. Assets load only on wp-login.php and any pages you opt into via the Integrations tab. The JS check uses a tiny inline script with no external request. Geo lookups from CDN headers are zero-latency. API fallback results are cached per IP for a configurable period. If you opt in to the early-block mu-plugin, it turns away locked-out IPs before WordPress fully loads.

What happens if the CAPTCHA API goes down?

All providers fail open. A network or API error never locks out legitimate users.

Will this conflict with other security plugins?

It hooks specifically into WordPress login actions and standard WooCommerce and form-plugin hooks. If another plugin hooks the same actions it may conflict. Open a support thread with details if you see an issue.

Can I use this without any CAPTCHA?

Yes. Set the provider to None. Geo-blocking, brute-force lockout, honeypot username trapping, the JS presence check, and 2FA all work independently of CAPTCHA.

Does it work with WooCommerce?

Yes. The WooCommerce My Account login, registration, lost-password, checkout, and order-tracking forms each have their own toggle in the WooCommerce section of the Integrations tab.

I locked myself out. How do I get back in?

Two options. First, add define( 'NAHNLS_BYPASS_IP', 'your.ip.address' ); to wp-config.php (above the “That’s all, stop editing” line). It accepts a comma-separated list of IPs and CIDR ranges, and exempts them from lockouts, the IP blocklist, geo blocking and the early-block rate limit – no deactivation needed. Second, rename the plugin folder from nahnu-login-shield to _nahnu-login-shield via SFTP, which deactivates it. If you are stuck at the two-factor step instead, see the next question.

Can I put my own username on the honeypot list?

Yes, and it is a good idea: usernames are public (author pages, feeds, the REST API), so bots try them. Add your username to the Honeypot list on the Lockout tab and sign in with your email address from then on. Anyone who tries the username is locked out like a bot. Email addresses of real accounts are never blocked, so patterns like admin@* do not affect your own sign-in. The Lockout tab lists which entries are real accounts and reminds you if your own username is on the list. If you get locked out anyway, add define( 'NAHNLS_DISABLE_HONEYPOT', true ); to wp-config.php (above the “That’s all, stop editing” line) to switch the honeypot list off, sign in, fix the list, then remove the line. To clear an IP that is already locked, also see the question above.

I can’t receive the 2FA email / I’m locked out

When two-factor authentication is on, every sign-in asks for a code, and email codes are the baseline. If the email does not arrive (a mail problem on the server, spam filtering), first try a backup code or “Email me a code” again. If that does not help, add define( 'NAHNLS_DISABLE_2FA', true ); to wp-config.php (above the “That’s all, stop editing” line). This switches the 2FA check off for everyone, so you can sign in with just your password; the plugin’s settings page shows a notice while it is set. Fix email delivery (an SMTP plugin usually does it), add an authenticator app on your Login & security page so you are not dependent on email, then remove the line. Note: NAHNLS_BYPASS_IP does NOT bypass 2FA – it only exempts addresses from lockouts, the IP blocklist, geo blocking and the early-block rate limit.

Can my login, registration and My Account pages be cached?

Mostly yes. Every protected form carries a hidden security token that lives about a day. On page load the plugin’s small script fetches a fresh token (one request to admin-ajax.php), so pages served from a full-page cache keep working as long as JavaScript runs – including cached blog posts with a comment form. Without JavaScript, a cached copy of the form older than a day fails the security check and asks the visitor to reload. Login, registration and My Account pages should still be excluded from full-page caching (WooCommerce requires this anyway). Developers can lengthen the token life with the nahnls_form_nonce_life filter.

Is this compatible with multisite?

It is not tested on multisite and is not recommended for network activation.

How does geo-blocking work when I do not use a CDN?

It falls back to one of two free IP geolocation APIs (freeipapi.com or ipinfo.io) with a configurable cache. CDN headers are always checked first and take priority.

How do I get a new form plugin supported?

Open a support thread or submit a request at https://nahnuloginshield.com/support/. Bricks Builder, SureForms and WordPress comments are the supported integrations today; anything else can be wired up through the developer API (docs/API.md) while a request is considered.

What is the mu-plugin and is it safe to have?

The mu-plugin is optional and opt-in. Nothing is copied until you, as an administrator, click Install early-block mu-plugin on the General tab. That button copies nahnls-early-block.php from the plugin folder into your must-use plugins directory (WPMU_PLUGIN_DIR, normally wp-content/mu-plugins/). The file checks whether the requesting IP is locked out or rate-limited and, if so, sends a 403/429 response before WordPress fully loads — dramatically reducing server load during bot floods. The General tab shows whether it is installed, not installed or outdated; after a plugin update you are offered an Update mu-plugin button (it is never refreshed automatically). Clicking Remove deletes the file, and it is also removed on plugin deactivation and deletion. If the directory is not writable, the settings page shows manual copy instructions instead.

The per-IP rate-limit counters the mu-plugin uses are tiny text files stored inside your WordPress uploads directory at wp-content/uploads/nahnu-login-shield/ratelimit/ (protected by an index.php and .htaccess; files older than five minutes are pruned automatically). Nothing is written outside the WordPress installation; the folder is deleted when the plugin is uninstalled.

Can attackers bypass the lockout by rotating IPs?

The per-username lockout catches this: if the same username is attempted from too many different IPs within the time window, the username itself is locked regardless of IP. Adding common targets (admin, administrator, root) to the Honeypot username list gives the strongest protection — one attempt from any IP is enough to lock both the IP and the username globally.

Screenshots

Changelog

1.0.19

Third performance release, for very high login volumes.

  • New: an installed early-block mu-plugin is refreshed automatically when the plugin is updated. It is still only installed when you click the button.
  • New: optional “Strict” mode for Require JavaScript. A login without the JavaScript marker is refused before the password is checked, and with the mu-plugin before plugins and the theme load. Off by default: a custom login form that posts to wp-login.php without the marker would stop working.
  • Changed: edge blocks and lockout emails are queued and handled in batches. A burst of lockouts is one background task and one Bunny Shield API call, not one of each per IP.
  • Changed: early-block mu-plugin: the custom login address is checked for lockouts and rate-limited like wp-login.php.
  • Changed: the country lookup cache uses the plugin’s counters table, not four options rows per visitor.
  • Changed: the edge-block log is written once per batch.
  • Fixed: long (escalated) lockouts are now pushed to Bunny and Cloudflare too, not only the short ones.
  • Fixed: the Bunny pull-zone block list now uses the same connection as Shield blocking: the wp-config constants or the Cache Connector, not only the saved key.
  • Fixed: a blank recipient box for the admin login alert or the weekly digest now falls back to the Alert email, then the site’s admin email, instead of sending nothing.
  • Fixed: settings text: the proxy header order, the country cache description, and two button and switch names.

1.0.18

Second performance release, for sites that see thousands of bot logins a day. Two small database tables are added automatically. If you use the early-block mu-plugin, click “Update mu-plugin” on the settings page after updating.

  • Changed: active lockouts are stored one row per IP in their own table. Before, every lockout lived in a single option that was read in full on each login request and rewritten in full on each new lockout; with thousands of locked IPs that was megabytes per request. Existing lockouts are moved over automatically.
  • Changed: failed-attempt counters (per IP and per username) use a small counters table instead of transients, so a failed login no longer writes four rows to the options table.
  • Changed: a login attempt this plugin has already refused (locked IP, blocked IP, honeypot username) no longer goes on to WordPress’s user lookup and password check, and is no longer also counted as an ordinary failed login.
  • Changed: writing an event-log row takes one query instead of two.
  • Changed: no background task is scheduled for a lockout when there is nothing to do (no edge blocking and no email for that event).
  • Changed: database upgrades run on the first request after an update, so background auto-updates no longer wait for someone to open wp-admin.
  • Changed: early-block mu-plugin: reads the new lockouts table when its marker files are not available.
  • Changed: Plugin Check clean-up: prefixed variables in the mu-plugin and the uninstaller, stricter handling of posted numbers, and older changelog entries moved to changelog.txt.

1.0.17

Performance release for sites under heavy bot traffic. If you use the early-block mu-plugin, click “Update mu-plugin” on the settings page after updating.

  • Changed: early-block mu-plugin: a locked-out IP is now answered from one small file, with no database query and no rate-limit bookkeeping. Normal page views leave the mu-plugin after a few string checks.
  • Changed: early-block mu-plugin: an IP that keeps hitting the login rate limit (three busy minutes, or three times the limit in one minute) becomes a real lockout, so it is also pushed to Bunny or Cloudflare when edge blocking is on. Before, it was answered with a 429 forever.
  • Changed: early-block mu-plugin: with a custom login slug, direct hits on wp-login.php get a bare 404 (or the home redirect) before plugins and the theme load.
  • Changed: early-block mu-plugin: the manual blocked-IP list and recently blocked countries are refused before plugins load, and the settings whitelist is respected.
  • Changed: blocked-IP and blocked-country hits write one event-log row per IP per minute instead of one per request.
  • Changed: rate-limit data is a fixed-size counter per IP; old files are removed by the daily cron instead of during login requests.
  • Changed: the settings screen code is only loaded in wp-admin, not on front-end page views.

Earlier versions: see changelog.txt in the plugin folder.