Authentication for e-commerce: guest checkout, accounts, and fraud
A shopper fills a cart, reaches the login wall, and a sizable share of them leave rather than create an account. That is not a security failure; it is an auth failure that your revenue dashboard records as abandoned carts. E-commerce is the rare place where the login screen is simultaneously your biggest conversion leak and your most-attacked surface. The same form that annoys a legitimate buyer into leaving is the one credential-stuffing bots hammer thousands of times a minute. You cannot optimize one without considering the other.
Guest checkout is the default, not the exception
The single highest-leverage decision in e-commerce auth is letting people buy without an account. Forcing registration before purchase is a conversion tax you pay on every first-time buyer. The pattern that works is buy first, offer the account after: capture the email and shipping details needed to fulfill the order, complete the payment, then on the confirmation page offer a one-click upgrade to a full account using the credentials they already typed.
Technically, a guest is still an identity. You want a stable record keyed on email so you can attach the order, send tracking, and later reconcile it if the person creates an account with the same address. Treat the guest as a lightweight identity that can be promoted, not as a throwaway row.
-- Guest and registered users share one identity table.
-- A guest simply has no password credential yet.
CREATE TABLE identities (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
email citext NOT NULL,
email_verified boolean NOT NULL DEFAULT false,
kind text NOT NULL DEFAULT 'guest', -- 'guest' | 'registered'
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (email)
);
-- Promote a guest after checkout: attach a password, flip the kind.
UPDATE identities
SET kind = 'registered'
WHERE email = 'buyer@example.com'
AND kind = 'guest';Account creation that survives the second visit
The reason to want accounts at all is retention: saved addresses, order history, faster repeat checkout, and loyalty. But the account only helps if the returning customer can actually get back in. Password reset is the real login path for most e-commerce users, because people shop twice a year and forget. Make reset fast, make it work from the same device the order confirmation email was opened on, and offer passwordless email links or passkeys so there is no password to forget in the first place.
Social login (Apple, Google) cuts friction but introduces an account-collision problem: a guest who bought with buyer@example.com and later clicks "Sign in with Google" using the same address must land on the same identity, not a duplicate. Reconcile on verified email and merge order history.
Credential stuffing is the attack you will actually see
E-commerce logins are targeted with reused credentials from unrelated breaches because stored cards, loyalty points, and saved gift-card balances are cashable. The attack is high-volume and distributed, so per-IP rate limits alone are useless. You need layered controls: rate limiting keyed on the account and the IP, device fingerprinting, and a risk score that escalates to a step-up challenge only when something looks off, so the 99% of honest logins stay frictionless.
// Escalate only on risk, so real shoppers rarely see a challenge.
function loginDecision(ctx: LoginContext): Decision {
const score = riskScore(ctx); // IP reputation, failed-attempt velocity, new device, impossible travel
if (score < 30) return { action: "allow" };
if (score < 70) return { action: "step_up", method: "email_otp" };
return { action: "deny", reason: "high_risk", log: true };
}Pair this with breach-password detection at both registration and login: if a customer's chosen password appears in a known-compromised set, force a change. It is the cheapest single defense against stuffing, because it removes the reused credentials attackers rely on.
Card-testing and account creation abuse
Fraud in e-commerce is not only about stolen logins. Attackers create accounts in bulk to test stolen card numbers, abuse first-order discount codes, and farm loyalty signups. Your signup endpoint needs the same risk thinking as login: disposable-email detection, velocity limits per device and per card BIN, and a quiet hold on orders that trip multiple signals rather than an outright block that tips off the fraudster.
Sessions that respect the shopping journey
A browsing session and a checkout session are not the same trust level. Someone can stay logged in for weeks to browse and build wishlists, but the moment they add a new shipping address, change the account email, or spend stored value, require a fresh authentication. This step-up model keeps the long, sticky session that drives engagement while putting a real barrier in front of the actions a hijacker would take. A stolen session cookie should be able to window-shop and nothing more.
Where this leaves you
E-commerce auth is a negotiation between the marketing team that wants zero friction and the fraud team that wants a wall. The resolution is risk-based: cheap and invisible for the honest majority, expensive precisely where money moves. Getting that balance right means owning the signals end to end, which is hard to do when your login lives in a black-box SaaS that meters you per monthly active user and hides the risk engine. Running identity you control, like Bastionary, lets you tune the conversion-versus-fraud tradeoff for your own catalog instead of accepting someone else's defaults.
Run it yourself
Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.