Hand-written login code guards everything in a Legacy PHP system. How to move to standard identity and multi-factor authentication without locking users out.
Open the code of an older PHP application and you will often find that the login page was written by hand. So was the "forgot password" email, the "remember me" checkbox and the screen where staff reset a customer's account. Each was built once, often by someone who has since left, and rarely reviewed again.
That code guards everything else, so a flaw in it is a risk to every account and every record behind it. Modernisation is a natural moment to stop maintaining your own front-door lock and move to a standard one, and to add multi-factor authentication (MFA) while you're at it. It's also a moment when a careless switch can lock out your own customers or leave a side door open.
The decision you're facing
The decision is whether to keep sign-in as custom code inside the application, or hand it to a dedicated identity provider: a service, either hosted by a vendor or run by you, whose only job is to confirm who someone is. Your application then trusts the identity provider's answer instead of checking passwords itself.
They talk using open standards. The most common for web sign-in is OpenID Connect, built on another standard called OAuth 2.0. In plain terms, OpenID Connect is an agreed format for a trusted service to say "this is who the person is, and this is how they proved it". The OpenID Foundation describes it as "an interoperable authentication protocol based on the OAuth 2.0 framework", and says that, for the applications relying on it, it "removes the responsibility of setting, storing, and managing passwords which is frequently associated with credential-based data breaches."
The second half of the decision is MFA: asking for a second proof beyond the password, such as a code from an app, an approval on a phone, or a security key. CISA's guidance is direct: "phishing-resistant MFA is the standard all industry leaders should strive for, but any MFA is better than no MFA." It adds that "the only widely available phishing-resistant authentication is FIDO/WebAuthn authentication", the technology behind security keys and passkeys, where the device itself refuses to sign in to a fake website.
The current revision of NIST's authentication guidance, SP 800-63B-4, published in 2025, points the same way. It is written for US federal systems, but it is a useful benchmark for anyone. It says verifiers "SHALL offer at least one phishing-resistant authentication option" at its middle assurance level, and it drops some old habits: it says organisations "SHALL NOT require subscribers to change passwords periodically", unless there is evidence a password has been compromised.
What goes wrong when it's done carelessly
Moving sign-in is one of the more sensitive steps in any migration, because every user passes through it. These are realistic ways it can go wrong. They are potential outcomes, not documented incidents.
- Mass lockouts. Users who changed phone numbers or lost access to an old email address suddenly can't get in. Support is swamped, and the pressure to "just let people in" grows.
- A recovery route that bypasses everything. The new sign-in has MFA, but the old "forgot password" page or a staff "reset account" screen still works and asks only for an email address. An attacker uses the weaker door.
- Two doors open during the switch. For a period, the old PHP login still works for some pages or a mobile app. Forgotten, it keeps accepting passwords long after everyone assumes it is gone.
- MFA fatigue. CISA's fact sheet on number matching describes "MFA fatigue", also known as "push bombing": an attacker who already has a password keeps sending approval prompts to the user's phone "until the user either approves the request by accident or out of annoyance". NIST's guidance describes the same pattern and calls it "authentication fatigue".
- Vendor lock-in. If the application is wired to one provider's own features rather than the open standards, leaving that provider later can mean another migration.
- Weak second factors. CISA's phishing-resistant MFA fact sheet notes that text-message codes are vulnerable to phishing and to SIM swap attacks, where criminals persuade a mobile operator to move a user's number to their own SIM card.
The defensive approach to identity and multi-factor authentication
At the level of concepts, a defensive move to standard identity has five parts.
1. Find every door first. List every way someone can prove who they are today: the main login, admin panels, password reset, "remember me", staff impersonation tools, API keys, mobile app sign-in and any single sign-on you already have. The new identity provider must cover all of them, or each one must be deliberately retired.
2. Choose a standard, then a provider. Insist that your applications talk to the identity provider through OpenID Connect or another open standard, not through one vendor's private interface. The OpenID Foundation notes that the protocol is designed "to encourage an open ecosystem" of identity providers. Keeping to the standard is what keeps your exit route open.
3. Move sign-in in stages, with a way back. Start with staff and administrators, who are fewer, easier to support and often the most valuable target. Then move customers in groups. Keep a tested way to send a group back to the old login while problems are fixed, and set a firm date to remove it. How existing passwords move across, and how users stay signed in while two systems run side by side, are separate decisions that need their own plan.
4. Introduce MFA with recovery designed in. NIST advises that organisations "SHOULD encourage subscribers to maintain at least two separate means of authentication" to reduce the need for account recovery. In practice, that means letting users register a backup method before MFA becomes mandatory, and making account recovery at least as strong as sign-in itself. For push approvals, CISA recommends number matching, where the user must enter the number shown on the login screen into their app, as an interim step where phishing-resistant MFA isn't yet possible.
5. Close the old doors and watch the new one. Once a group has moved, switch off the legacy login and reset paths for that group rather than leaving them dormant. Watch for unusual sign-in failures, bursts of MFA prompts and spikes in recovery requests: early signs of both user friction and attack.
Where Node.js fits, and where it doesn't
A modern Node.js application can work well with standard identity: well-maintained OpenID Connect libraries let new code trust the identity provider instead of handling passwords itself. Depending on the application, that may remove a whole category of hand-written security code.
But Node.js isn't the reason this works; the standard is. The same move can be made by a current, well-maintained PHP application, and many teams sensibly do it before any rewrite begins. Equally, a Node.js team that writes its own login code from scratch is repeating the original mistake on a newer stack. Libraries need updating, the identity provider needs careful setup, and someone must own both.
What this means for your organisation
Ask these questions of your own system:
- Who wrote your login, password reset and "remember me" code, and when was it last reviewed by someone else?
- What percentage of your staff and administrators use MFA, and which type?
- If a customer loses their phone, what exactly is the recovery process, and could an attacker follow it with only an email address?
- If you chose an identity provider today, how hard would it be to leave it in three years?
- When the new sign-in goes live, who confirms that the old login has actually been switched off?
Recommended next step
Before choosing any product, draw up an inventory of every sign-in and recovery path in your application, who uses each one and what it protects. That one document tells you how big the move is, which group of users should move first, where MFA matters most and which old doors must be closed. Our Free Security and Modernisation Review is built to give you that view: where your current application is exposed, sign-in and recovery included, and the safest route to a secure, modern platform.
Free Security and Modernisation Review
Sketchmonk is a security-led software engineering company. Our engineers have built software for a national defence research lab, global cyber security vendors and security-first product companies, with 16+ years of engineering behind them. In a free Security and Modernisation Review, we look at the application you run today: where it is exposed, what it depends on, and the safest route to a secure, modern platform. Want to see how we have handled problems like yours? Ask for a case study in the same email. There's no obligation to proceed.




