skip to content

Token Placement and Session State

The consequences of where auth context lives: cookie-backed sessions vs bearer tokens, self-contained JWTs vs opaque tokens needing introspection. Interviewers use it to connect the statelessness constraint to real logout, revocation, and CSRF tradeoffs.

part ofAPI stylesoverview, primer and where to startread it →
on this pageshow

questions

3

Compare a self-contained signed token, such as a JWT whose claims the API validates locally, with an opaque token that the API must resolve by calling an introspection or lookup service. What does each cost at request time?

level: middleimportance: must knowfreq 68%

basics

~20 s

A self-contained token carries its claims and a signature, so the API validates it locally with no lookup: fast and dependency-free, but the claims are a snapshot valid until expiry. An opaque token is a random string the API must resolve remotely: always current and instantly revocable, at the cost of a call on every request.

open as a page

With a self-contained token used as the API credential, what does logout actually accomplish, and how do you design revocation so that disabling an account takes effect quickly without a lookup on every request?

level: seniorimportance: should knowfreq 60%

basics

~20 s

Client-side logout only discards the local copy; a stolen token still works until it expires. Design for it: keep access tokens short-lived, store the refresh credential server-side so it can be deleted, and if you need faster, check a small replicated denylist or a per-user token version.

open as a page