Authentication: passwords, MFA, sessions and tokens
Separate identity verification from permissions, and understand the responsibilities around passwords, MFA, sessions, JWT validation and account recovery.

On this page
Authentication establishes an identity for a user, service or device. Authorisation then decides which operations that identity may perform. A successful login does not grant access to every resource or guarantee that an account cannot be compromised.
Passwords and account protection
Password authentication checks a secret known by the user. Protect it in transit with TLS and use an established salted, costed password-hashing scheme for storage. A fast general-purpose SHA digest or reversible password encryption is not a suitable substitute.
Allow password managers and sufficiently long passwords, screen against compromised/common choices, and protect recovery and password-change flows. Login throttling and detection help address guessing and credential stuffing; account lockout itself can be abused to deny service, so choose controls deliberately.
Credential stuffing uses leaked credentials from another service. Brute-force guessing explores candidate secrets. Neither is solved simply by making the login page harder to find.
Multi-factor and biometric authentication
MFA combines evidence from different factor categories, such as possession and knowledge. Two passwords are not two independent factors. A fingerprint used to unlock a hardware-backed authenticator is different from sending raw biometric data to a server.
MFA reduces some risks, but methods differ in phishing resistance. Recovery, session theft and social engineering remain relevant. Do not promise that an attacker with a stolen password can never enter an MFA-protected account; the complete enrollment, authentication and recovery design matters.
Biometric measurements are sensitive and not readily replaceable like a password. Prefer established platform authenticators rather than designing a biometric database or protocol in the application.
Sessions and tokens
A session identifier references server-managed state. Generate it securely, rotate it when appropriate, expire it and invalidate relevant sessions on logout or security events. Browser cookies need suitable Secure, HttpOnly and SameSite settings, alongside CSRF protections where applicable.
A token carries or references authorization information. Its format does not establish a revocation policy. Self-contained tokens can remain valid until expiry unless the system adds an explicit revocation or state-checking mechanism.
For JWTs, a signed token is not necessarily encrypted. Validate the allowed signature algorithm and trusted key, issuer, audience, expiry and other protocol-specific claims. Do not accept an unverified payload because it can be decoded. A JWT is a format, not a complete login protocol.
Federation and application boundaries
OAuth supports delegated authorization. OpenID Connect adds an identity layer for authentication; they are not interchangeable names for login. Prefer established libraries and current protocol guidance over a custom implementation. An access token intended for one API must not automatically be accepted by another.
Authentication checks also do not replace per-request resource authorization. Validate the user's right to the particular object and operation on the trusted server side. Least privilege and role design belong to that authorization layer.
Mobile, device and cloud considerations
Mobile applications must account for lost devices, secure storage and network changes. Use supported platform facilities and avoid shipping a shared client secret as though an installed application could keep it confidential.
For IoT, consider device identity, credential provisioning, rotation and retirement, including physical access. Cloud systems add service identities, federation and a shared-responsibility boundary. Central identity management can improve consistency, but it does not configure every application's permissions automatically.
Log meaningful authentication events without credentials or unnecessary personal data. Test denial paths, recovery and session expiry as well as successful login. Security is a maintained system property, not a guarantee supplied by any one authentication method.
References
Written by Alex Hovy.
← Back to BlogsContinue reading
Replacing an identity server: ASP.NET Core Identity and OpenIddict
Migration considerations for user management, OAuth/OpenID Connect contracts, credentials and operations, with clear distinctions between identity products.
Authorisation: resource permissions and trusted enforcement
Design understandable access rules, enforce object-level permissions and account for service boundaries, caching and revocation.
Encryption: confidentiality, integrity and key management
How encryption differs from hashing and signatures, where it protects data, and why key management and authenticated protocols matter.