← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 019 · Security and data protection

Design a Login Service

Easy 35 min

Design the login service for a company with 10 million users and a dozen backend services. Users sign in with an email and password or through Google or GitHub (OAuth). After login the service issues a short-lived access token that other services verify on their own, plus a refresh token to keep the user signed in. Attackers regularly try leaked passwords against the login endpoint. At peak there are about 400 login and token-refresh requests per second.

Functional requirements

  • Sign up and log in with email and password
  • Log in with Google or GitHub through OAuth
  • Issue a 15-minute access token and a longer-lived refresh token
  • Revoke a user's refresh tokens on logout or password change

Non-functional requirements

  • Passwords are never stored or logged in plain text
  • Brute-force and credential-stuffing attempts are throttled
  • Other services verify tokens without calling the login service
  • Logins complete in under 1.5 seconds at p95, including OAuth

Constraints and scale

  • 10 million users
  • 400 login and refresh requests per second at peak
  • Signing keys must be rotated every 90 days without logging users out

You will practise

  • Store credentials safely with a slow, salted password hash
  • Issue signed tokens and verify them without a central lookup
  • Protect a login endpoint from brute-force attacks and keep secrets out of code
Show 2 hints
  1. Why is a fast hash like SHA-256 a poor choice for passwords?
  2. If access tokens are verified locally, how does a revoked user eventually lose access?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A credential-stuffing attackAttackers replay 50 million leaked email/password pairs from 20,000 IP addresses, about 3,000 attempts per second.

Run them from the workspace once your design is in place.