Support multiple JWT issuers with separate JWKS
Problem
A single PostgREST instance may need to accept JWTs from several identity providers. Each provider has its own issuer value, signing keys, and expected audiences.
For example, a multi-tenant application may use a different identity provider for each customer.
PostgREST accepts a JWKS with multiple keys, but it does not bind separate key sets to separate issuers. Combining all providers' keys into one JWKS loses that distinction. A token signed by provider A must not be accepted as a token from provider B.
Solution
Allow administrators to configure multiple trusted JWT issuers, each with its own JWKS source and allowed audiences.
PostgREST would use the token's iss claim to select a configured issuer, then verify the token using only that issuer's keys and validation rules. Reading iss to select an issuer would not make the claim trusted. Unknown issuers would be rejected, and key lookup by kid would stay within the selected issuer's key set.
A first version could support local JWKS files and configuration reloads. Remote fetching and OpenID Connect Discovery could build on the related issues below.
Existing single-JWKS configuration should keep working. The configuration format and how the two modes interact are open for discussion.
Example
The configuration could represent the following data. This is an illustration, not a proposed configuration syntax:
{
"issuers": [
{
"issuer": "https://identity.customer-a.example",
"jwks": "@/etc/postgrest/customer-a.jwks.json",
"audiences": ["customer-a-api"]
},
{
"issuer": "https://identity.customer-b.example",
"jwks": "@/etc/postgrest/customer-b.jwks.json",
"audiences": ["customer-b-api"]
}
]
}Both providers could authenticate requests to the same PostgREST instance while keeping their keys and audience rules separate. Applications would still map verified identities to tenants and enforce access through database permissions and RLS. This proposal does not include login flows, token issuance, or automatic tenant selection.
Related issues
- #1130 — Load public keys from a well-known endpoint.
- #4137 — Retrieve JWKS using OpenID Connect Discovery.
- #2099 — Allow multiple configured audiences.
Those issues cover key fetching and audience configuration. This proposal adds the binding between each trusted issuer and its own keys and audiences.
Source: PostgREST/postgrest