Interview Q&A · questions with model answers

Authentication Interview Questions

Part of the study plan for: Backend Engineer · Full Stack Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked How do you secure session cookies?

    Set HttpOnly (no JavaScript access), Secure (HTTPS only), SameSite=Lax or Strict (limits cross-site sending), a narrow Path/Domain, sensible expiry, and use the Host- prefix where possible.…

  2. Most asked How do you protect login endpoints from brute force and credential stuffing?

    Rate-limit by IP, account and device fingerprint; add progressive delays or temporary lockouts; use bot detection/CAPTCHA after failures; check passwords against breached lists; require MFA; and…

  3. How do you design a secure password reset flow?

    Generate a random, single-use, short-lived token (store only its hash), email a link containing it, verify the token on use, let the user set a new password, invalidate the token and all existing…

  4. How do you implement logout correctly across sessions and tokens?

    Destroy the server-side session and clear the cookie; for tokens, revoke the refresh token (and optionally denylist the access token's jti until expiry); for SSO, perform RP-initiated logout with…

  5. How would you implement admin impersonation safely?

    Issue a separate, clearly marked impersonation session that records both the admin and the target user, restrict which admins and accounts can be impersonated, log every action with both identities,…

  6. How do you authenticate WebSocket connections?

    Authenticate during the handshake: send the session cookie (same-site) or a short-lived token (query parameter or first message), validate it before accepting, check the Origin header, and…

  7. How do you safely link social logins to existing accounts?

    Only link accounts when the provider asserts a verified email and the user proves control of the existing account (logs in or confirms via email). Store the provider's stable subject ID (sub), not…

Was this page helpful?

Report a mistake