useGrant

Tenant

What a tenant is and how it validates tokens.

A tenant acts as an identity broker: it validates tokens issued by the external identity providers it trusts. Each tenant can trust multiple identity providers, one for each authentication source.

Caution

If you use tenants on behalf of your customers, create one tenant per customer. This keeps each customer's identity providers isolated, so one customer's tokens can never be validated against another customer's provider.

Identity providers and policies

Identity provider: an external OpenID Connect issuer the tenant trusts, such as GitHub Actions. You configure its issuer URL, the expected audience, and optionally the earliest issuance time allowed, which rejects tokens issued more than the given number of hours ago.

Policy: a set of rules attached to an identity provider. A policy sets the expected audience and optional conditions on token claims, for example sub stringLike repo:octo-org/octo-repo:*. Conditions support the stringEquals, stringNotEquals, stringLike and stringNotLike operators. Every token is validated against a specific policy.

Illustration

Here is how a tenant validates a token in a typical request flow:

ClientIdentity providerYour serveruseGrantmatch issuercheck exp · audpolicy conditionsverify signature1. Request tokenSigned JWT2. Request + JWT3. Validate token4. Discovery + JWKSPublic keys5. Valid · { exp }6. Response
  1. The client requests a token from its identity provider, which issues a signed JWT.
  2. The client sends the JWT to your server.
  3. Your server asks useGrant to validate the token against a tenant policy.
  4. useGrant matches the token's issuer to an identity provider configured on the tenant, then checks the header type, expiration, issuance time, audience and policy conditions. Finally, it fetches the provider's public keys through OpenID Connect discovery and verifies the signature.
  5. useGrant returns the result, including the token's expiration time, to your server.
  6. If the token is valid, your server grants access or issues its own short-lived token for the request.

This flow is the same no matter which identity provider issued the token.

On this page