Skip to main content

Shared resources

A plan that validates tokens — a jwt or an oauth2-remote plan — describes the authorization server that issues them: its issuer, its keys, its endpoints, the client the gateway uses with it. On thirty APIs, that is thirty copies of the same identity provider, and a change of its keys is thirty changes. A shared resource names it once for the workspace (APIs → Shared resources), and the plans reference it rather than describing it again.

Like a shared policy group, it creates no gateway capability:

  • the resource has a draft and published versions, immutable;
  • a plan pins a version (its tab Access → Shared authorization server); the next snapshot of the API freezes that version, and the projection derives from it exactly what the plan would derive from a description of its own — the JWT verifier of a jwt plan, the auth module of an oauth2-remote plan, marked as the product's, reconciled, removed with the API;
  • publishing a new version changes nothing that runs: the page of the resource lists the APIs that pin it, and the ones behind the latest version; publishing tells their teams, and Upgrade the N behind moves them, each by its own draft and, when asked, its own snapshot and deployment — as for a shared policy group (otoroshi-apim shared-resources upgrade <ws> <resource> [--publish] [--deploy]);
  • a resource that a plan still pins cannot be deleted;
  • its name is one in the workspace: a declarative document pins it by that name (sharedResource: { name: Corporate IdP, version: 1 }), and so moves from one installation to the next.

What stays the plan's own: the claim the client id is read in, the audiences a token must carry (the audience of this API at the server), the user profile an oauth2-remote plan fetches. The issuer is the server's.

note

These are the resources of the composition model — a dependency a policy consumes —, not the resources of an API, its endpoints. An authorization server is the first kind; others (a token cache, a directory) would come the same way.

The client secret of the gateway at the server is kept in the versions and the snapshots as it is given: prefer a vault reference (${vault://…}).