OIDC Jwt Token Example

Published
Length
3 min read

Luis Felipe Dias

All posts

An oidc jwt token example shows three text parts joined by dots. These parts hold the header, user claims, and cryptographic signature for login. Engineering teams set up OpenID Connect to centralize user logins across their apps. Identity providers issue these tokens after a user signs in. Still, teams often map broad group claims directly to admin database or server roles. When a token grants full role permissions, one bad query can break production data. How an oidc jwt token example works

Token Rotation + K8s OIDC Authentication: the complete guide

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

Free white paper. No spam. Unsubscribe anytime.

An oidc jwt token example shows three text parts joined by dots. These parts hold the header, user claims, and cryptographic signature for login. Engineering teams set up OpenID Connect to centralize user logins across their apps. Identity providers issue these tokens after a user signs in. Still, teams often map broad group claims directly to admin database or server roles. When a token grants full role permissions, one bad query can break production data.

How an oidc jwt token example works in practice

Every JSON Web Token in OpenID Connect splits into three base64-encoded strings. The first part is the header, which names the signing algorithm and key identifier. The app reads this header to find the right public key from the provider. It fetches that key from a public endpoint to check the token signature later.

The second part is the payload, which holds claims about the user login event. Standard claims include the issuer URL, the subject ID, and the target audience ID. The payload also holds the issue time and the exact expiration time for security. Teams often add custom claims here, such as user email addresses or group names. Downstream systems read these group names to pick a local role for the user.

The third part is the signature, which proves the provider signed the token data. The provider hashes the header and payload together using its private cryptographic key. If anyone changes a group name in the payload, the signature check will fail. The target app rejects any token that fails this math check or passes expiration.

How to validate claims in your login flow

Your app must run strict checks on every token before it allows user login. First, the app fetches the public keys from the identity provider discovery endpoint. Next, it checks the cryptographic signature to confirm the token came from that provider. Never trust the payload claims until this signature check passes without any errors.

After the signature check, the app must read and check the core payload claims. It checks that the issuer matches your identity provider and the audience matches your app. Then it checks the current clock against the expiration claim to stop old tokens. Once these checks pass, the app maps the user group claims to internal permissions.

Token Rotation + K8s OIDC Authentication: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What OIDC tokens solve and what they leave open

OpenID Connect solves the hard problem of proving who a user is across apps. Teams no longer need to store passwords inside every single database or internal tool. When a worker leaves the company, admins disable one account in the identity provider. That user can no longer mint new tokens or log in to company systems.

Still, a valid token only proves identity at the moment the session starts. It cannot see or control what the user does after they log in. A developer with a valid token might still run a destructive drop table command. They might also query a table full of customer emails, phone numbers, or card numbers. The token grants the broad role, and the database trusts every command in that session. Identity checks alone cannot inspect live queries or rewrite sensitive fields in 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 runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values 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

What is the difference between an ID token and an access token?

An ID token proves who the user is to the client app during login. An access token tells a backend API what actions that user can run.

Can anyone read the data inside a standard OIDC JWT?

Yes, anyone with the token can decode the base64 header and payload to read claims. The signature stops tampering, so you should never put raw secrets inside payload claims.

How long should an OIDC token stay valid before it expires?

Teams should keep token lifetimes short, often between five minutes and one hour. Short lifetimes limit the risk if an attacker steals a token from a user device.

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.