Skip to main content

Shared policy groups

Otoroshi gets its power from composition — plugins chained in flows. The flip side is that a composition exists nowhere as an object: it is rebuilt by hand on thirty APIs, and nobody can point at "our company policy". A shared policy group names it and makes it governable.

It creates no new gateway capability: a group is a chain of ordinary Otoroshi plugins, projected inline in the flows of the APIs that use it.

Lifecycle​

Like an API, a group has a draft and published versions, immutable and numbered:

  1. APIs → Shared policy groups → New group, add Otoroshi plugins with their native configuration.
  2. Publish v1.
  3. In an API, Policies & flows → Add policy group: the flow pins the latest published version.

Pinned, never floating​

An API references a group at a version. Its snapshot freezes the plugins of that version, and the projection expands them in place. Its name is one in the workspace: a declarative document pins it by that name, and so moves from one installation to the next. Publishing v2 of the group changes nothing in production: snapshots are immutable.

The group page lists the APIs that use it and which ones are behind; the flow of each API shows "v2 available · Upgrade". Upgrading is an edit of the API's draft, then a publication — what runs only ever changes through a snapshot.

A fix still travels, without propagating by itself:

  • publishing a version tells the teams of the APIs behind, in their notifications, with a link to the group — the administrators of the workspace for an API of no team;
  • Upgrade the N behind, on the group page, moves them to the latest version at once — each API by its own draft and, when asked, its own snapshot and its own deployment (only where it runs), every step in the audit trail. An API the upgrade cannot touch is reported, not forced: managed by a source (a catalog, Kubernetes: upgrade it there), not managed by you (left to its team), or whose draft holds other unpublished changes — its draft is upgraded, its publication left to its team, since publishing would ship those changes along.
otoroshi-apim policy-groups list default
otoroshi-apim policy-groups upgrade default "Company security headers" --deploy

A flow referencing a group without a version is a draft error, and a group cannot be deleted while an API uses it.

Through the admin API​

H='Authorization: Bearer apim-admin-token'
curl -X POST http://localhost:9000/api/workspaces/default/policy-groups -H "$H" -H 'Content-Type: application/json' \
-d '{"name": "Company security headers", "plugins": [
{"plugin": "cp:otoroshi.next.plugins.AdditionalHeadersOut",
"config": {"headers": {"X-Company-Policy": "v1"}}}]}'
curl -X POST http://localhost:9000/api/workspaces/default/policy-groups/<id>/publish -H "$H" \
-H 'Content-Type: application/json' -d '{"comment": "v1"}'

In a draft, a flow references a group with { "group": "<id>", "version": 1 } among its plugins.