Jwt Token Issuer and Audience

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up jwt token issuer and audience checks by matching token claims against trusted strings. The issuer claim names the login server, and the audience claim names the target app. Teams often copy one broad token setup across many internal services to save time. When roles are too broad, a token meant for one app can open other systems. Attackers or buggy scripts can then reuse that valid token across your whole network. How jwt token issuer and audience claims work A JSON Web Token holds

Token Rotation: the complete guide

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

Free white paper. No spam. Unsubscribe anytime.

You set up jwt token issuer and audience checks by matching token claims against trusted strings. The issuer claim names the login server, and the audience claim names the target app. Teams often copy one broad token setup across many internal services to save time. When roles are too broad, a token meant for one app can open other systems. Attackers or buggy scripts can then reuse that valid token across your whole network.

How jwt token issuer and audience claims work

A JSON Web Token holds signed facts about a user or a machine. The login server writes these facts when a user logs in. The issuer claim tells the receiving app which server signed the token. The receiving app reads this string and checks its list of trusted login servers. If the issuer string does not match, the app drops the request right away.

The audience claim tells the receiving app who should accept the token. A single login server often creates tokens for dozens of different internal apps. Without an audience check, a token for the billing app works on the user database. The target app must check that its own unique name sits inside the audience claim. When both the issuer and audience match, the app trusts the user identity.

How teams check token claims in practice

First, the security team gives every internal service and database a unique name. The login server adds this exact name to the audience field when minting a token. Next, developers set up their apps to fetch public keys from the login server. The app uses those keys to check the cryptographic signature on every incoming token.

After the signature passes, the app checks the expiration time, the issuer, and the audience. Every single check must pass before the app lets the user log in. Teams also rotate signing keys on a set schedule to limit the life of stolen keys. Good key hygiene and strict claim checks stop outsiders from forging or replaying tokens.

Token Rotation: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What token checks solve and what they miss

Checking the issuer and audience solves the problem of who can log in. It stops a valid token from opening the wrong app in your stack. It also proves that a trusted login server created the token for that exact service. This native setup gives you a strong front door for your apps and databases.

Still, token claims only check the user at the moment they log in. They do not inspect what individual queries, commands, or requests do in flight. Once an engineer or an AI agent passes the token check, they get full role access. A valid token will not stop a careless script from dropping a production table. It also cannot rewrite sensitive fields like emails, phone numbers, or card numbers in query results. Teams still need a way to check every command and mask data in real time.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can one token have more than one audience claim?

Yes, a login server can put a list of target app names in the audience field. Teams should keep this list short so one token cannot open too many systems.

What happens if an app skips the audience check?

Any user with a valid token from the same login server can log in. A low-trust app could then send its own users' tokens to a high-trust app.

Do token claims control which database rows a user sees?

No, standard issuer and audience claims only prove where the token came from and where it goes. They do not filter live queries or rewrite matched fields like national IDs in results.

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.