Skip to content

JWT for inference

Last updated: 2026-11-22T07:30:00-03:00 (UTC-3)

Instead of distributing virtual keys, your applications can call the gateway with a JWT access token issued by your identity provider. The gateway checks the signature and binds the token’s sub to an existing virtual key, which defines models, scopes and team. Flag: jwt_inference.

The gateway does not issue tokens and does not turn claims (roles, scope, groups, team) into permissions: everything comes from the bound key.

features:
identity_management: true
jwt_inference: true # boot; requires PostgreSQL
jwt_auth:
issuer_url: https://identity.example.com
audience: ai-gateway-inference
jwks_url: https://identity.example.com/keys
algorithms: [RS256, ES256]
allowed_origins: [https://identity.example.com]
allowed_private_cidrs: []
allow_loopback_http: false
max_ttl_seconds: 900
clock_skew_seconds: 30
bindings: []
Field Rule
issuer_url The trusted issuer, compared exactly with the token’s iss; HTTPS
audience Exact. Must be different from the client ID of the console SSO
jwks_url A fixed URL, with no query or fragment. The gateway never discovers keys from the token
algorithms The signature algorithms the gateway accepts: RS256 and/or ES256; any other alg is refused
allowed_origins Exact origins, no wildcards
allowed_private_cidrs Allowed private networks (RFC 1918 or ULA), listed explicitly
allow_loopback_http HTTP only for localhost, in development
max_ttl_seconds 60 to 3,600; exp - iat cannot exceed this
clock_skew_seconds 0 to 60 seconds of tolerance for the identity provider’s clock when the gateway checks exp, nbf and iat
bindings subject → key_id bindings to an existing managed key

Changing the issuer, audience, JWKS, algorithms, limits or network is a trust change: it requires a rollout and a review of the bindings.

The issuer must produce this format on purpose: a generic JWT or an IdP’s default configuration is not automatically compatible.

In the console: Virtual keys → Inference JWT bindings, for the global admin only (jwt:manage). It shows the issuer, audience, trust fingerprint and up to 1,000 subjects.

Through the API:

Endpoint Body
GET /api/v1/admin/jwt-bindings —
PUT /api/v1/admin/jwt-bindings {subject, key_id, disabled, version, trust_fingerprint}
DELETE /api/v1/admin/jwt-bindings {subject, version, trust_fingerprint}; reverts to the YAML or removes the binding
  • What is edited in the console takes precedence over the YAML. disabled: true denies the subject even if the YAML has a binding.
  • A stale version, changed trust or exceeded capacity return 409; a key that does not exist returns 404.
  • key_id is the real ID of a managed key, as it appears in Virtual keys. YAML keys cannot be bound.
  • Every change goes into the audit log; tokens are never stored.
Terminal window
curl http://localhost:8080/v1/models \
-H "Authorization: Bearer $ACCESS_TOKEN"

On every request, the gateway resolves the binding and checks the key (expiry, revocation, active team) in the database. It then applies the same models, scopes and team policy as an ordinary key. Disabling the binding, revoking the key or changing the policy takes effect on the next request.

  • Format: compact JWS of up to 16 KiB; a header with only alg, kid and typ; typ equal to at+jwt or application/at+jwt. ID tokens (typ: JWT) are refused.
  • Refused: none, HMAC, JWE, embedded keys, key URLs (jku, x5u) and JSON with duplicate keys.
  • Claims: exact iss; aud equal to the audience (or a list containing only it); sub required; exp, iat and nbf required.
  • JWKS: up to 32 keys and 256 KiB, unique kid, use: sig. RSA from 2,048 to 8,192 bits or EC P-256. Private and symmetric keys are refused.
Situation Response
Invalid token, signature or subject; expired or revoked key 401
JWKS, trust or database unavailable; more than 32 concurrent verifications 503

Errors do not expose the token, the claims or the JWKS.

  • The JWKS is cached for 5 minutes. After that, if the refresh fails, no old key authorizes anything.
  • At most one refresh every 30 seconds. An unknown kid within that interval is refused: when you rotate the signing key, publish it with a new kid.
  • The JWKS fetch connects only to approved IPs, with no proxy or redirect, and a 5 s timeout.

Console SSO and inference JWT have independent issuers, audiences, JWKS and caches. A console session does not become an inference token, and an access token does not open the console. route:* covers only inference routes: it grants no access to MCP or administration. The token is never sent to the provider.

  • A token can be replayed while it is valid: there is no replay protection by jti, no proof of possession (DPoP) and no revocation of an individual token. To cut off access, disable the binding or revoke the key.
  • Removing a signing key from the JWKS can take up to 5 minutes to take effect; revocation in the database is immediate.
  • It is not an OAuth authorization server: no issuance, no introspection and no full RFC 9068 conformance.
  • Turning the flag off stops JWT authentication; ordinary keys keep working and the bindings are kept.

Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.

Route What it does
GET /api/v1/admin/jwt-bindings Lists the subject-to-key bindings (bindings) with the trust fingerprint writes must name
PUT /api/v1/admin/jwt-bindings Binds one subject to an existing managed key, or changes that binding

max_ttl_seconds is required when a JWT trust block is present and accepts 60–3,600 seconds; zero is invalid. clock_skew_seconds accepts 0–60 seconds, with omitted or explicit zero allowing no clock skew. These constraints share the typed backend policy and still validate a present block when inference JWT is disabled. They are not new public scalar catalog entries or console trust controls. Binding management retains its own authorization and versioning; changing boot trust requires rollout.

m7gtwcontact@m7gtw.com