Skip to content
← All articlesEngineering

Authentication for Web and Mobile Apps: OAuth, SSO, Passkeys

A practical guide to app authentication: when to use OAuth 2.0, OpenID Connect, SSO and passkeys, and whether to build or buy login for your product.

Login looks like a solved problem until you have to build it. A single sign-in screen hides decisions about identity providers, token storage, session lifetime, account recovery and enterprise customers who insist on single sign-on. Get these wrong and you face either security incidents or an expensive rewrite once a large customer asks for SSO.

This guide is for founders, CTOs and product managers who need to make sensible authentication choices before development starts, or who are reviewing a proposal from an outsourced team.

Authentication vs authorisation

The two words are often mixed up, and so are the tools:

  • Authentication answers “who is this user?”
  • Authorisation answers “what is this user allowed to do?”

OAuth 2.0 is an authorisation framework: it lets an app obtain limited access to a resource on a user’s behalf. OpenID Connect (OIDC) is a thin identity layer on top of OAuth 2.0 that adds a standard way to say who the user is. If your requirement is “Sign in with Google” or “log in through the customer’s company account”, you want OIDC, not bare OAuth.

The main options

Approach Best for Watch out for
Email and password Simple products, early MVPs Password storage, resets, credential stuffing
Social login (OIDC) Consumer apps wanting low friction Users without that provider; account linking
Magic links or one-time codes Low-frequency or B2B tools Email delivery reliability
Passkeys (WebAuthn) Phishing-resistant, modern UX Device and recovery flows need design
Enterprise SSO (SAML or OIDC) B2B SaaS selling to larger companies Per-customer configuration and support
Multi-factor authentication Anything holding sensitive data Adoption friction; recovery paths

Most products combine two or three of these. A common pattern is passwordless or social login for individuals and SSO as a paid or enterprise-tier feature.

Build or buy?

For almost every product, writing your own identity system is the wrong investment. Password hashing, rate limiting, breach detection, MFA, session revocation and audit logs are all areas where subtle mistakes become vulnerabilities.

Consider a managed identity service or a mature open-source identity server when:

  • You need SSO, MFA or social login soon and do not want to maintain them.
  • You expect enterprise customers who will ask for SAML or SCIM provisioning.
  • Your team is small and engineering time is better spent on the product.

Building in-house can make sense if you have unusual regulatory needs, must keep identity data in a specific region, or the vendor’s pricing model does not fit your user volumes. Whichever route you choose, keep identity behind a clean interface in your code so switching later is a contained change rather than a rewrite.

Web vs mobile: different threat models

Web and mobile apps need different handling even when they share one backend.

Web apps

  • Prefer secure, HttpOnly, SameSite cookies for sessions over tokens stored in local storage, which any injected script can read.
  • Use the authorisation code flow with PKCE for single-page apps. The older implicit flow is discouraged.
  • Protect against cross-site request forgery where cookies are used.

Mobile apps

  • Use the system browser or the platform’s authentication session for OAuth flows, not an embedded web view.
  • Use PKCE, because a mobile app cannot keep a client secret confidential.
  • Store refresh tokens in the platform keychain or keystore, never in plain preferences.
  • Offer biometric unlock as a convenience layer on top of a proper session, not a replacement for it.

Passkeys: worth planning for now

Passkeys, built on the WebAuthn and FIDO2 standards, replace passwords with cryptographic keys held on the user’s device, often synced through the platform’s credential manager. They resist phishing because the credential is bound to your domain. Major platforms and browsers support them, so adding passkeys as an option next to existing login methods is increasingly practical.

Design the fallback carefully. Users lose phones, and a weak recovery path can undo the security you gained.

Sessions, tokens and logout

Decide these points explicitly rather than accepting library defaults:

  • Access token lifetime (short) and refresh token lifetime (longer, rotated).
  • What “log out everywhere” means and how revoked sessions are enforced.
  • Idle and absolute session timeouts that suit your risk level.
  • How roles and permissions are checked on the server for every request, never only in the interface.

A checklist for your next project

  • Chosen identity approach documented, including build or buy reasoning
  • Authorisation code flow with PKCE for browser and mobile clients
  • Rate limiting and lockout on login and reset endpoints
  • MFA available, and required for admin accounts
  • Account recovery flow designed and tested
  • Audit log for sign-ins, permission changes and password resets
  • SSO requirements confirmed with your first enterprise prospects
  • Security testing of the auth flows before launch

Getting authentication right with a delivery partner

Authentication touches the backend, the web front end and every mobile client, so it benefits from one team owning it end to end. If you are scoping a product, our web development and mobile app development teams in Chennai can design and build secure login flows for you. See also our mobile app security checklist and REST API design best practices. When you are ready to talk through your requirements, contact us.

Let’s build what’s next.

Tell us about your platform, your product idea or the systems you want to modernise. Someone from our Chennai engineering team will get back to you personally.