Jwt Segments

Published
Length
3 min read

Luis Felipe Dias

All posts

A JSON Web Token splits into three jwt segments separated by two dots. These parts are the header, the payload, and the cryptographic signature. Engineering teams set up token checks to let users and services log in. Still, many apps grant broad permissions based on a single role claim. When a token holds wide rights, any service with that token can run dangerous commands. How jwt segments structure identity and claims Every token uses three distinct strings encoded in URL-safe Base64 format.

Segments: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

A JSON Web Token splits into three jwt segments separated by two dots. These parts are the header, the payload, and the cryptographic signature. Engineering teams set up token checks to let users and services log in. Still, many apps grant broad permissions based on a single role claim. When a token holds wide rights, any service with that token can run dangerous commands.

How jwt segments structure identity and claims

Every token uses three distinct strings encoded in URL-safe Base64 format. Dots join these three pieces so any app can split and read them.

The first part is the header. It tells the receiving app which signing algorithm created the token. It also declares the token type so the parser knows what to expect. Teams must check this header first to stop attackers from swapping signing methods.

The second part is the payload. This section carries claims about the user or service account. Standard claims include the issuer, the subject ID, and the expiration timestamp. Teams also put custom role names or group lists inside this middle part. Because Base64 is not encryption, anyone who gets the token can read the payload. Teams should never place secrets or passwords inside these claims.

The third part is the signature. The identity server creates it by hashing the first two parts with a secret key. When an app receives the token, it checks the signature with its validation key. If someone edits a role in the payload, the signature check fails right away.

How teams validate tokens across internal services

To check a token, an app splits the string at the two dots. Next, it decodes the header and picks the right public key. The app then runs the signature check over the raw header and payload strings. Only after the signature passes should the app read the payload claims.

Segments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

The app then checks the expiration time and the audience claim. An audience check makes sure a token meant for billing cannot work on admin systems. Many teams cache public keys from their identity provider to keep this check fast. Once these checks pass, the app trusts the user identity inside the token.

What token validation solves and where gaps remain

Validating all three parts proves who sent the request and that no one altered the claims. It lets stateless apps check identity without calling a central database on every request. This setup works well for basic login flows across web apps.

Still, a valid token only decides who logs in at the start of a session. It does not inspect what individual queries, commands, or API requests do in flight. A developer or automated tool might hold a valid token with a broad admin role. Once past the token check, that user can run destructive queries or dump full tables. Standard token checks also leave no audit log of the exact statements run during the session. Also, static claims cannot rewrite sensitive data like emails, phone numbers, card numbers, or national IDs in query results.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can anyone read the data inside jwt segments?

Yes, the header and payload use simple Base64 encoding rather than encryption. Anyone with the token can decode and read the claims in plain text. Never store raw passwords, secret keys, or private customer data inside a token payload.

What happens if a token is missing one of the three parts?

A valid token must always have two dots that separate three distinct parts. If the signature part is empty or missing, the receiving app must reject the request. Accepting unsigned tokens lets attackers forge any user identity or role claim they want.

How do teams revoke a token before it expires?

Signed tokens are stateless, so apps trust them until the expiration time passes. To block a token early, teams must keep a shared deny list of revoked token IDs. Setting short expiration times of five to fifteen minutes also limits the risk of stolen tokens.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.