Call the gateway with your identity provider's tokens
From 1.14.0, a workspace can let callers reach /v1 with an access token from the company's own identity provider,
instead of a DVARA API key. The gateway checks the token, maps it to the workspace, and records the person it names on
the audit record and the cost record of every call.
Not included in DVARA Open Source. It runs with or without a licence.
It is off by default. A workspace accepts tokens only after its admin turns it on. API keys keep working beside it, so you can move callers over one at a time.
Use it when:
- your people already sign in to an identity provider, and you want each call costed and audited to the person, not only to a shared key;
- your services already get tokens from the identity provider, and you do not want to hand out and rotate one more secret.
How a token is checked
A workspace trusts one issuer. For each call that carries a token, the gateway:
- finds the workspaces that trust the issuer named in the token's
issclaim; - checks the signature against the keys that issuer publishes at its JWKS URL, with one of the algorithms the workspace allows;
- checks that
issmatches exactly, and thatexpandnbfare within the clock skew. A token with noexpis refused; - checks that the token's
audnames one of the workspace's audiences; - checks every required claim, and reads the user claim.
Exactly one workspace must accept the token. If none does, the call is refused with 401. If two would, the call is
also refused, so a token meant for one workspace never acts in another (see
Keep two workspaces apart).
The gateway then treats the call as it treats a call with an API key. Scopes, IP access rules, rate limits, budgets, policies, PII handling, guardrails and audit all apply. The token is never written to a log, an audit record or a cost record.
Send the token where you would send an API key. The gateway reads it from the same headers, in the same order:
Authorization: Bearer <access-token>
x-api-key (the Anthropic Messages API) and x-goog-api-key (the Gemini API) carry a token too. A credential that is
not shaped like a signed token, such as a gw_ API key, is checked as an API key, as before.
Keys are cached. The gateway keeps an issuer's key set for 5 minutes. A token signed with a key it does not know makes it fetch the key set again, at most once every 30 seconds, so a rotated key works within seconds. A token signed with a retired key is refused.
Turn it on for a workspace
There are two pages with the same form:
- A workspace admin opens Identity → Identity Provider. It covers their own workspace only. A
developerorviewercannot open it. - A platform owner opens Access → Workspaces, edits the workspace, and follows Identity provider in the
Access section. A
policy-adminorbilling-admincan read this page but cannot save it.
Fill in the form and click Save identity provider:
| Field | Default | What it does |
|---|---|---|
| Accept tokens from this identity provider | Off | Turns token sign-in on for this workspace |
| Issuer | None; required | Exactly the iss value in your tokens. One value, no spaces, at most 512 characters |
| JWKS URL | None; required | Where the identity provider publishes its signing keys. HTTPS only |
| Audiences | None; at least one | The aud values a token may carry, separated by commas. At most 10. Every token must name one |
| Signing algorithms | RS256 | Any of RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, ES512 and EdDSA. None chosen means RS256 |
| User claim | sub | The claim that names the person on the audit record and the cost record. Its value must be text or a number, at most 256 characters |
| Clock skew (seconds) | 60 | How far exp and nbf may be off. 0 to 300 |
| Required claims | None | One name=value per line, at most 10. A token must carry each one. For a claim that holds a list, such as groups, the list must contain the value |
| Endpoints a token may call | None: every endpoint | The same scopes as an API key, such as completions:write or models:read |
The form refuses a save that has a problem, lists every problem, and writes nothing. It refuses:
- a missing issuer, JWKS URL or audience while the switch is on;
- an algorithm that is not on the list.
noneand shared-secret algorithms such asHS256are never accepted; iss,aud,exp,nbforiatas a required claim, because they are checked already;- an unknown scope;
- a JWKS URL that is not HTTPS, or that points at a loopback, link-local or cloud metadata address;
- a JWKS URL on a private network, unless the page allows it (see below);
- an issuer and audience that another workspace already trusts with the same required claims.
The setting reaches the gateways with the workspace's other settings on the configuration bundle. A gateway applies a change within about 5 seconds of taking the bundle. No restart is needed.
Private networks. An identity provider inside your network, such as a Keycloak server on a private address, is
allowed from the platform page by default (dvara.admin.egress.allow-private-networks, default true). From the
workspace admin's page it is refused unless the operator sets dvara.portal.egress.allow-private-networks=true
(default false). The gateway applies the same rule when it fetches the keys. It never follows a redirect, and it
reads at most 512 KiB of keys.
Set up your identity provider
Each provider needs an API, or a client, for the gateway, so that its tokens carry an audience the gateway can check.
Microsoft Entra ID
- In App registrations, register an application for the gateway, for example
dvara-gateway. - Under Expose an API, set the Application ID URI and add a scope, for example
access. - In the application's Manifest, set
"accessTokenAcceptedVersion": 2, so its access tokens use the v2.0 issuer below. - Let your callers ask for the scope: a user signs in to a client application that requests
api://<app-id>/access; a service uses the client credentials flow withapi://<app-id>/.default.
Then fill in the form:
| Field | Value |
|---|---|
| Issuer | https://login.microsoftonline.com/<tenant-id>/v2.0 |
| JWKS URL | https://login.microsoftonline.com/<tenant-id>/discovery/v2.0/keys |
| Audiences | The gateway application's client ID, which v2.0 tokens carry in aud |
| User claim | oid (the user's object ID), or preferred_username for a name you can read. A service's token has no user, so use azp for services |
| Required claims | tid=<tenant-id> |
Entra ID signs with RS256, the default.
Okta
Use a custom authorization server, such as default. Tokens from the org authorization server are for Okta's own APIs
and should not be trusted here.
- In Security → API → Authorization Servers, open the server (or add one) and note its issuer and audience.
- Add a scope for the gateway, and an access policy that lets your client applications ask for it.
| Field | Value |
|---|---|
| Issuer | https://<your-org>.okta.com/oauth2/default |
| JWKS URL | https://<your-org>.okta.com/oauth2/default/v1/keys |
| Audiences | The server's audience, api://default unless you changed it |
| User claim | sub (the user's sign-in name, or the client ID for a service token), or uid |
Okta signs with RS256, the default.
Keycloak
- In your realm, add a client for the gateway, for example
dvara-gateway. - Keycloak access tokens do not name your API by default. On the client that your callers use, add an Audience
mapper that puts
dvara-gatewayin the access token'saud.
| Field | Value |
|---|---|
| Issuer | https://<keycloak-host>/realms/<realm> |
| JWKS URL | https://<keycloak-host>/realms/<realm>/protocol/openid-connect/certs |
| Audiences | dvara-gateway |
| User claim | preferred_username, or sub |
Keycloak signs with RS256 by default. A Keycloak server on a private address needs the private-network setting
above.
Make a call
Get an access token from your identity provider, then call the gateway with it:
curl -s https://<gateway-host>/v1/chat/completions \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'
The answer is the same as with an API key. In Flightdeck, the call's audit record names the issuer and the user.
Keep two workspaces apart
Two workspaces can trust the same issuer, as long as each token can match only one of them. Give each workspace its own audience, or a required claim that only its tokens carry, such as a group:
| Workspace | Audience | Required claim |
|---|---|---|
payments | dvara-gateway | groups=payments-ai |
claims | dvara-gateway | groups=claims-ai |
Flightdeck refuses a save when another turned-on workspace trusts the same issuer, shares an audience and has the
same required claims. If a token still matches two workspaces, for example a person in both groups, the gateway
refuses it with 401 idp_token_ambiguous and serves neither.
What each call records
The audit record. A call made with a token writes the usual GATEWAY_RESPONSE record, with these fields added:
| Field | Value |
|---|---|
auth_method | idp_token |
idp_issuer | The token's issuer |
end_user | The value of the workspace's user claim |
idp_subject | The token's sub, only when it differs from the user claim |
api_key | dvara-idp-<workspace-id> |
The cost record. The call's user tag is the user the token names. It wins over the request's user field and
over a user tag the caller sent, because the identity provider checked who that is. So spend by user, and budgets on
a user value, follow the person. See Cost attribution.
One key id per workspace. Every token call in a workspace is counted under the key id dvara-idp-<workspace-id>.
Usage, cost, rate limits and budgets that work per API key treat all of a workspace's token callers as one key. Use
the user tag to tell people apart.
Settings changes. Every save writes WORKSPACE_IDP_TOKENS_UPDATED to the audit trail, with the workspace, the
page it was saved from (workspace or platform), and the settings before and after. The settings hold no secret.
Resolve a refused token
A refused token gets 401, with error type authentication_error, in the error shape of the API the caller used. The
message says which check failed and never repeats the token:
| Code | Meaning | What to check |
|---|---|---|
idp_issuer_not_trusted | No workspace accepts tokens from this issuer | The switch is on, and Issuer matches iss exactly, including any trailing / |
idp_signature_invalid | The signature did not check against the issuer's keys | The JWKS URL belongs to this issuer |
idp_algorithm_not_allowed | The token is signed with an algorithm the workspace does not allow | Signing algorithms; none and HS256 are never accepted |
idp_token_expired | exp is in the past, beyond the clock skew | Get a new token |
idp_audience_not_trusted | aud names none of the workspace's audiences | Audiences; on Keycloak, the audience mapper |
idp_claim_mismatch | A required claim is missing or has another value, or the user claim is not short text | Required claims and User claim |
idp_keys_unavailable | The gateway could not fetch the issuer's keys | The JWKS URL is reachable from the gateways. Try again later |
idp_token_ambiguous | More than one workspace accepts the token | Keep two workspaces apart |
idp_token_invalid | The token is not a well-formed signed token, or its claims are not acceptable, such as no exp or no user claim | The token your client sends |
A token that passes these checks but lacks a scope the endpoint needs gets 403 api_key_scope, as an API key does.
The refusal is written to the audit trail as a GATEWAY_RESPONSE record with status: 401 and the code. When only
one workspace trusts the token's issuer, the record goes to that workspace's audit log.
Turn it off for a gateway
To stop a gateway accepting tokens for every workspace, set dvara.llm-gateway.idp-tokens.enabled=false
(DVARA_LLM_GATEWAY_IDP_TOKENS_ENABLED=false) and restart it. The workspace settings are then ignored, and /v1
takes API keys only. See the
configuration reference
for the gateway's other key-fetch settings.