Custom Private Login & Registration
| AI Plugin Information | |
|---|---|
| Version | 15 |
| Download | Download Plugin |
Custom Private Login & Registration
A WordPress plugin that replaces the login, registration and account-recovery flows with an anti-enumeration design.
Knowing an email address is not enough. Controlling the email address is what grants access to account-specific information and functionality.
An unauthenticated visitor cannot learn from this site whether an address has an account, whether that account has ever set a password, what its username is, or why an authentication attempt failed.
Requirements
- WordPress 6.5 or later (the Script Modules API)
- PHP 8.0 or later
Layout
aiplugin5010.php Main plugin file: hooks, wiring, asset enqueues
readme.md
src/
├── aiplugin5010/ PHP, namespace aiplugin5010
│ ├── Support/ Options, Messages, Request, Logger, Timing, Urls
│ ├── Services/ Tokens, rate limiting, mail, password state,
│ │ access requests, registration, abuse reports
│ ├── Views/ LoginForm (additions to WordPress's own login
│ │ form), Branding, Honeypot, Screens
│ ├── Controllers/ One per wp-login.php surface
│ ├── Hooks/ AuthGuard, RestHardening, Activation
│ └── Admin/ SettingsPage, SecurityPage
├── js/
│ ├── login.js Entry module for the login screen
│ ├── admin.js Entry module for the settings screen
│ ├── support/ Email shape check, animation primitives
│ ├── ui/ LoginFlow, LoginForm
│ └── controllers/ LoginScreenController, MethodSettingsController
└── css/ login.css, admin.css
No build step, no Composer, no autoloader. Every class is required explicitly
in aiplugin5010.php; every JavaScript module is a native ES module loaded by
the browser from its relative import path.
How the flows work
The login screen
wp-login.php is the standard WordPress login screen. The plugin does not
render a form of its own: it adds its controls to core’s form through the hooks
core provides, so everything else that renders there — a Log in with Google
button from a social-login plugin, for instance — keeps its place on the screen.
What the plugin adds:
- The logo above the form, from the configured URL or the theme’s site logo,
filterable through
aiplugin5010_login_logo. - A nonce and a honeypot inside the form, which is what makes the Get Link action on it safe to accept.
- Email me a sign-in link, standing where core’s “Lost your password?” link stands, since here they are the same request.
- The methods enabled in settings that another plugin advertises through the
aiplugin5010_auth_methodsfilter. Email is on that list only for the script below: without it, the email method is the credentials form, so its button is printed hidden. SMS is present but disabled and has no delivery implementation.
The form has four controls and two distinct submit actions:
| Action | Behaviour |
|---|---|
| Log In | Attempts authentication. Never sends email. |
| Get Link | Requests an access email. Ignores the password field. |
Get Link submits the login form — so it carries the address already typed — but sits after the form’s own submit button, so pressing Enter in a field always means Log In and never sends an email. Nothing on the screen needs JavaScript.
One step at a time
That whole screen is what the server sends. A browser that runs the script module shows it a step at a time instead:
| Step | What is on the screen |
|---|---|
| The methods | One button per method: Login with Email, and every other login button the screen carries, whoever rendered it. Nothing is written above them – each button says what it is. The credentials form is put away. |
| The other methods clear, and a single email field is left standing. | |
| A valid address | Password and Email Link slide down beneath the field. |
| Password | Those two give way to the password field and Log In. |
Email Link presses the Get Link control the server already put on the screen, so what leaves the browser is the request described above, and what comes back is the same standardized confirmation.
Every step is decided in the browser, from what has been typed and nothing else. No step asks the server about the address, so the flow is not a second way to ask this site whether an address has an account: the address check decides when to offer the next step and nothing more, and the server validates and rate-limits every submission as it always did. Movement between steps is animated with the Web Animations API, and a visitor who has asked for reduced motion is shown the same steps without the movement.
The flow is email-first: it offers the password step once an email address has been typed. WordPress’s field still accepts a username, and a submission carrying one is authenticated exactly as before, but the scripted steps will not open for it.
A visitor whose browser does not run the module gets the screen described above: the standard form, whole, with every control on it. The only control the flow needs that the form does not already have — a button for the email method — is printed hidden, so it exists for the script and for nobody else.
Turning the Email method off in settings removes the credentials form and
leaves the remaining methods, core’s login_form hook still firing so that the
controls other plugins render there are unaffected.
Get Link
Rate limits are applied before the account lookup, so a limited address and an
unlimited one behave the same from outside. Whatever happened, the browser gets
A link has been sent to your email.
The access email offers Log In Now, Set Password and, secondary to both, Report this request.
Registration
The registration form takes an email address and nothing else. No WordPress user is created until the verification link is redeemed. An address that already has an account gets an ordinary access email; the person who typed it into the form sees exactly the same page either way.
Recovery
There is no separate lost-password flow. Core’s lost-password screen still
collects the address — so anything hooked into that form keeps working — but the
submission is handled as the same Get Link request, and core’s own
retrieve_password() is prevented from sending mail for logged-out callers. An
administrator sending a reset from the Users screen still works.
Security model
| Requirement | Where it lives |
|---|---|
| One public message set | Support/Messages.php |
| Response-time floor | Support/Timing.php |
| Expiring, single-use tokens | Services/TokenService.php |
| Email flood and brute-force limits | Services/RateLimiter.php |
| Password-set metadata | Services/PasswordState.php |
| Core error normalization | Hooks/AuthGuard.php |
| REST and author-scan hardening | Hooks/RestHardening.php |
| Security event log | Support/Logger.php |
Tokens are stored as transients keyed by a SHA-256 hash of the token, so the usable secret exists only in the delivered email. Redeeming one action from an email retires its sibling; changing a password retires everything outstanding for that account. Token values never reach the log.
password_set
Stored as private user meta (aiplugin5010_password_set).
- Accounts created by the plugin’s registration flow start at
no. - Accounts created any other way are recorded as
yesonuser_register. - Accounts that predate activation are migrated to
yes, because WordPress always set a password for them.
The value is never read to decide what a visitor is shown.
Extending
// Advertise a login method owned by another plugin.
add_filter( 'aiplugin5010_auth_methods', function ( $methods ) {
$methods['google'] = [
'label' => 'Google',
'description' => 'Continue with your Google account.',
'available' => true,
'url' => my_plugin_oauth_start_url(),
];
return $methods;
} );
A plugin that already prints its button on core’s login_form action does not
need this filter: the login screen is the standard one, so that button is
already on it.
Other extension points:
| Filter / action | Purpose |
|---|---|
aiplugin5010_login_logo | Change the image above the login form |
aiplugin5010_public_message | Change standardized wording |
aiplugin5010_account_eligible_for_email | Suppress delivery for an account |
aiplugin5010_validate_password | Add password-strength rules |
aiplugin5010_client_ip | Resolve the client IP behind a proxy |
aiplugin5010_allow_core_password_reset | Re-enable core’s reset email |
aiplugin5010_log_entry | Filter or discard a log entry |
aiplugin5010_security_event | React to a recorded event |
aiplugin5010_abuse_reported | React to an abuse report |
Anything hooked here must keep responses non-enumerating: a public message must never vary with whether an address belongs to an account.
Administration
- Settings → Private Login — methods and order, the login logo, token lifetimes, flood and brute-force limits, hardening switches, public message wording, redirect URL.
- Users → Login Security — password-set status, last login, abuse reports
and the security event log. Both screens require
manage_options.
Tests
tests/
├── aiplugin5010.wpunit.yml Suite config (copied to wpunit.suite.yml)
├── aiplugin5010.StartupCept.php Smoke test (copied to StartupCept.php)
├── wpunit/ Security invariants
└── acceptance/ Browser-level flows
tests/acceptance/EnumerationCept.php is the regression test that matters most:
it drives a known and an unknown address through login, Get Link, registration,
recovery and the staged flow, and asserts the visible responses are
byte-identical. tests/acceptance/LoginFlowCept.php walks the flow itself, from
the list of methods to a signed-in session.
