HTTP API
About 739 words
The backend plugin's ID is tailscale, so its routes live under /api/tailscale on your backend. All three are GET. They use Backstage's default authentication: a request needs a user or service token, like any other plugin route. There's no permission check beyond that, and the data is rendered from the whole catalog with the plugin's own credentials.
The backend renders the overview from the catalog at most once a minute and serves the cached result in between.
| Route | Returns |
|---|---|
GET /api/tailscale/overview | every policy, rendered, with its problems and publishing status |
GET /api/tailscale/policies/:namespace/:name/file | one policy's file |
GET /api/tailscale/access?entity=<ref> | what concerns one catalog entity, per policy |
The TypeScript types of every response are exported from @spechtlabs/backstage-plugin-tailscale-common.
GET /api/tailscale/overview
curl -H "Authorization: Bearer $TOKEN" https://backstage.example.com/api/tailscale/overviewReturns an Overview:
| Field | Type | Meaning |
|---|---|---|
renderedAt | string | when the backend rendered it (ISO 8601) |
policies | PolicyView[] | every policy, ordered by name |
orphans | Diagnostic[] | Tailscale entities whose spec.target isn't a policy |
publish | map of policy entity ref to PublishStatus | for each policy with spec.publish |
A PolicyView has:
| Field | Meaning |
|---|---|
entityRef, name, title, description, tailnet, owner | from the policy entity |
publish | the policy's spec.publish |
renderedAt | when it was rendered |
text | the rendered policy file |
spans | which lines each entity rendered to, by section (1-based, inclusive) |
parts | the policy entity and its parts: ref, type, name, title, description, lines |
groups, hosts, tags, grants, ssh, nodeAttrs, autoApprovers, tests | each section, with every name resolved: what it was written as, what the file has, its kind, and the catalog entity behind it |
settings | the names of the top-level settings rendered from spec.settings |
catalog | catalog grants: enabled, covered (consumptions a grant entity already allows), local (inside a cluster), missingSource, invalid |
destinations | every grant destination with its class, reason, grants and the Services it may serve |
diagnostics | the policy's errors and warnings: severity, message, entityRef |
Grants carry origin: entity for grant entities, catalog for catalog grants. A catalog grant also lists its edges, the consumptions and allows it's made of.
A PublishStatus has repo, path, flow, branch, pullRequestBranch, a problem when the repository isn't allowed, and last: the time, outcome (opened, updated, pushed, up-to-date or failed), URL and error of the last run on this backend instance.
GET /api/tailscale/policies/:namespace/:name/file
curl -H "Authorization: Bearer $TOKEN" \
https://backstage.example.com/api/tailscale/policies/default/my-tailnet/fileReturns the rendered file of the policy entity tailscale:<namespace>/<name> as text/plain, with Content-Disposition: inline; filename="<name>.hujson".
404 with {"error": "No Tailscale policy tailscale:default/x"} when there's no such policy.
GET /api/tailscale/access?entity=<ref>
curl -H "Authorization: Bearer $TOKEN" \
"https://backstage.example.com/api/tailscale/access?entity=component:default/reporting"Returns an EntityAccess[]: one entry for each policy the entity appears in, as far as that entity is concerned. Policies where the entity has no identity, no grant in either direction and no Tailscale entity naming it are left out, so an entity off the tailnet gets [].
| Field | Meaning |
|---|---|
policy | entityRef, name, title, tailnet |
identities | what the entity is on the tailnet (a tag, a Service, a group, a login), whether it's a source, a destination or both, and where that comes from |
outbound | grants it's a source of |
inbound | grants it's a destination of |
sshInto, sshFrom | SSH rules into it and from it |
tags | tags it carries |
owns | tags it may give devices |
nodeAttrs | node attributes that apply to it |
approvals | what it may advertise without approval, and who may serve what it offers |
tests | tests whose source or destination is it |
appliesTo | Tailscale entities that list it in spec.appliesTo |
An entity's identities come from:
- a tag entity: its tag;
- a tag entity that lists the entity in
appliesTo: that tag; specht-labs.de/tailnet-srcon it: those tags, as a source;specht-labs.de/tailnet-dston it, or on an API it provides: those names, as a destination;- an auto approver that lets one of its tags serve a Service: that Service, as a destination;
- a Group: its tailnet group;
- a User: their login, and the tailnet groups of the Groups they're a member of.
400 with {"error": "entity must be an entity ref"} when entity isn't an entity reference with a kind; 404 with {"error": "No entity <ref>"} when the catalog doesn't have it.
