Card 11/ 12

ExerciseDifficulty: Advanced1 min

Practice: Choosing How Four Clients Authenticate

A partner's batch job, a single-page app, an internal payments service and a mobile app.

Choosing how a client authenticates means answering the four questions for that client. An online shop's API has four callers. Choose a method for each, and say how its access would be cut off.

  1. A logistics partner's nightly batch job, running on the partner's servers.
  2. The shop's own single-page web app, served from the same site as the API.
  3. The shop's internal payments service, called by the orders service.
  4. The shop's mobile app, acting for a signed-in customer.
Show the answers
Each client, the method chosen, where the proof travels, and how access is cut off
ClientMethodWhere it travelsHow access is cut off
Partner batch jobAPI key, or OAuth client credentialsA request headerRevoke the partner's key
Own single-page appSessionAn HttpOnly, Secure, SameSite cookieDelete the session
Payments serviceMutual TLSThe TLS handshakeStop renewing the orders service's certificate
Mobile appOAuth access tokens, short-lived, with a refresh tokenAuthorization: BearerRevoke the refresh token; the access token expires within minutes

The mobile app must not carry an API key: anything shipped in an app can be extracted, and one stolen key would speak for every installation. If the access tokens are JWTs, the API validates them with every check, and the short lifetime is what makes revocation workable.