Skip to content
Commitwise
Menu

JWT (JSON Web Token)

Also called: Bearer token, Access token

A signed token that carries claims (who the user is, what they may do, when it expires), so a server can verify a request without a database lookup.

Definition

A JWT has three Base64URL parts: a header, a payload of claims (sub, scope, exp, iss, aud) and a signature. The server verifies the signature with the issuer's key and checks expiry, issuer and audience. The payload is readable by anyone, so it must not hold secrets, and a token stays valid until it expires, which is why access tokens are short-lived and paired with refresh tokens.

In practice

A Spring Boot resource server validates the Bearer token on every request and reads the user id from jwt.getSubject().

Related terms

Esc

Type to search the whole site.