A JSON Web Token (JWT) is a compact, URL-safe format for exchanging JSON claims between parties, standardized in RFC 7519. Claims are name/value assertions about a user, another entity or the token itself. JWT is a claims format, not a login protocol or an automatic security guarantee.
Structure and Cryptographic Protection
The common signed compact form of a JSON Web Token is header.payload.signature. The header describes cryptographic metadata and may identify the token type; the payload holds claims. The signature component holds a digital signature or message authentication code (MAC). Base64url encoding supports compact transport but does not conceal the encoded contents. Encrypted JWTs use a different, five-part compact structure, so three components are not universal.
Common claims include iss, which identifies the issuer; sub, the subject; aud, the intended recipients; and exp, the expiration time on or after which the token must not be accepted. Applications may add custom claims. The base JWT specification does not make these claims universally mandatory. The surrounding application or protocol determines required claims and their interpretation.
Claims may be protected using JSON Web Signature (JWS), including digital signatures or MACs, and/or JSON Web Encryption (JWE). In the signed form, the signature or MAC protects the encoded header and payload against undetected alteration. HMAC uses a shared secret for creation and verification; asymmetric signatures use a private signing key and a corresponding public verification key. A public verification key does not provide confidentiality or restrict verification to an intended recipient.
Issuance and Validation
An issuer authenticates a user or otherwise establishes authority, then issues a JSON Web Token that the client presents where required on later requests. A JWT access token is commonly sent in the Authorization header using the Bearer scheme. Before trusting it, the recipient verifies cryptographic protection with trusted keys and permitted algorithms, checks the expected issuer, audience, applicable time limits and token purpose, then applies authorization policy.
The verification key must be associated with an accepted issuer; mathematical validity alone is insufficient. Decoding performs none of these checks. A valid signature does not prove the current presenter's identity, establish every claim as true or independently grant access.
Advertisement — FinchTrade.
FinchTrade services
Get startedToken Purposes and Representations
- Purpose: Access tokens authorize resource access. OpenID Connect ID tokens assert information about user authentication for a client and are not substitutes for API access tokens.
- Representation: Access tokens may be JWTs or opaque values, whereas OpenID Connect ID tokens are JWTs. Opaque tokens are an alternative representation, not a JWT subtype.
- Interpretation: Opaque tokens expose no locally interpretable claims to the holder and commonly rely on server-side lookup or introspection. JWTs carry claims that recipients can use after appropriate validation.
Distributed Validation and Single Sign-On
Self-contained claims can support distributed authorization by allowing local validation without retrieving a server-side session for every request. This does not make the whole system stateless or guarantee that the token contains every fact needed for a decision. Revocation, account status and changed permissions may still require additional checks.
Single sign-on (SSO) means signing in once to access multiple applications. In an OpenID Connect arrangement, an identity provider authenticates the user and supplies an ID token that the client validates. The JSON Web Token carries the assertion; the surrounding protocol, provider session and trust relationships supply the sign-on process. JWT alone does not establish SSO.
Security Limits
Signed-only claims are readable by token holders, so minimize sensitive information in a JSON Web Token and keep secrets server-side rather than relying on encoding. Encryption can provide confidentiality, but HTTPS and safeguards against token leakage remain important. A stolen bearer token can be replayed while it remains accepted. Expiration limits this exposure but does not prevent replay.
Where supported, a separately protected refresh token can obtain replacement access tokens without another login. Refresh is not inherent to JWT, and refresh tokens need not be JWTs.