Playout workspace/org auth migration¶
Sep 28 – Oct 1 2026. Covers CoreAPI (media, playback, scheduling,
distribution, provisioning, identity), PlayoutAdmin and
@playtelly/capability-apps 0.8.0.
The playout domains used to be open: anyone who could reach CoreAPI could list, edit or delete any organisation's media, channels and streamers. They now follow the same model as the ticketing admin routes — real RS256 authentication plus a permission check on every request — with one rule for who owns what:
| Level | Owns | Why |
|---|---|---|
| Organisation (business) | Streamers, caches, SLBs (infrastructure the org pays for) | One physical node serves every workspace of the org; the org decides which workspaces may use it |
| Workspace (app) | Media, playlists, transcoding/ingest presets, channels, channel groups, schedules/programs | The day-to-day content a team works on |
A token carries one organisation and no workspace. The workspace is always a
URL segment, and the server checks that the caller belongs to it. There is no
X-Organization-ID / X-Workspace-ID header trust on the new routes.
Route map¶
| Domain | Before | After | Permission |
|---|---|---|---|
| media | /api/v1/media/… |
/api/v1/media/:workspaceId/… |
workspace:media:view/upload/edit/delete, profiles workspace:settings:manage, playlists workspace:playlists:* |
| media (maintenance) | /media/retry-stuck, /storage-audit, /tenants, /convert-pdf/:key |
/api/v1/media/ops/… |
platform admin only |
| playback | /api/v1/playback/… |
/api/v1/playback/:workspaceId/… |
workspace:channels:view/manage, presets workspace:settings:manage |
| scheduling | /api/v1/scheduling/… |
/api/v1/scheduling/:workspaceId/… |
workspace:schedules:view/manage |
| distribution | /api/v1/distribution/… |
/api/v1/distribution/:orgId/… |
org:distribution:view/manage (colorbars: platform only) |
| unchanged | /media/status, /assets/*, /hooks/tusd |
same | public / machine-facing |
System rows (seeded transcoding profiles and presets, empty workspace_id) stay
visible from every workspace and are read-only through the API.
New and changed handlers¶
playback¶
| Method + path | Purpose |
|---|---|
GET /playback/:ws/streamers |
The streamers this workspace may use (see Streamer access). Thin payload: id, name, host, publicHost, httpPort, role, status, hasGpu |
PUT /playback/:ws/channels/:id/brand/:slot |
Upload a brand asset, multipart field file. slot is logo_light, logo_dark or poster |
DELETE /playback/:ws/channels/:id/brand/:slot |
Remove a slot (removing poster also removes the EPG thumbnail) |
GET /playback/:ws/channel-groups/:id/payload |
Preview of what devices receive for the group (any status), with the device filters ?category= ?language= ?channelType=. Needs only workspace:channels:view |
GET /playback/:ws/channel-groups/:id/categories |
Counted guide tabs/filters for the group |
POST /playback/:ws/channel-groups/:id/push |
Deliver a published group to the playout devices in spaceIds over MQTT |
PUT/GET … /channels/:id |
Channel JSON gains brand { logoLightUrl, logoDarkUrl, posterUrl, epgThumbUrl } |
Behaviour changes on existing handlers:
- Channel create — every
filePathin the client'singestConfigmust match a live media key of the caller's workspace (400 otherwise); originingestUrlmust beudp://orpl:///; each origin's streamer must be available to the workspace. - Channel update —
synopsisis saved asdescription;synopsis,primaryGenre,contentProviderand a group'sdescriptioncan now be cleared by sending""(an absent key still leaves the field alone; lists clear with[]). - Channel delete — removes the channel from its groups (bumping the version of published ones) and deletes its brand assets.
- Channel groups — only
readychannels may be added (400); publishing needs ≥ 1 channel and every channel present andready(409);draft → publishedand any lineup change of a published group raiseversion; re-saving a lineup that keeps a channel no longer fails with 500.
Brand assets¶
Stored in the media bucket under channels/<workspaceId>/<channelId>/brand/ (not
media rows, so they never appear in the media library). The browser crops to the
slot's shape; the server re-checks everything and re-encodes.
| Slot | Output | Source minimum | Shape |
|---|---|---|---|
logo_light, logo_dark |
512×512 PNG, alpha kept | 256×256 | 1:1 (±3 %) |
poster |
1920×1080 JPEG | 640×360 | 16:9 (±3 %) |
| EPG thumbnail | 400×225 JPEG, generated from the poster | — | 16:9 |
Accepted: PNG, JPEG, WebP, judged by content, ≤ 4 MB. SVG/GIF are rejected. Each upload gets a new timestamped key, so a replaced image gets a new URL.
distribution¶
| Method + path | Purpose |
|---|---|
GET /distribution/:org/streamers/:id/access |
{ accessMode, workspaceIds } |
PUT /distribution/:org/streamers/:id/access |
Set accessMode (all_workspaces | selected) and the granted workspace ids. Needs org:distribution:manage; every workspace must belong to the org |
Streamer access¶
Streamers stay org-owned. streamers.access_mode plus streamer_workspace_access
decide which workspaces may put channels on a node:
- Existing streamers default to
all_workspaces(nothing changes for them). - Streamers created through the API start
selectedwith no grants, so nobody can use a new node until the org opens it. - A revoked grant stops new channels from choosing the node; running channels are untouched.
provisioning (devices)¶
See Provisioning internals for the full payload. Summary of what changed:
GET /devices/:id/channels/groups— same URL, still unauthenticated, now read from the database. Optional filters?category=,?language=,?channelType=.GET /devices/:id/channels/categories— counted tabs/filters.- Payload gains
id,channelType,logoLight,logoDark,poster,publicUrl,primaryGenre,genres,languages,tags,keywords,customGroups,contentProvider,categories.urlis exactly as stored (unchanged). - The old unauthenticated
POST /devices/:id/channels/publish/:groupIdandPOST /spaces/:id/channels/publish/:groupIdare kept for Tellyboard (same contract); they now read the group from the database because the HTTP call they used to make no longer exists. PlayoutAdmin uses the authenticatedpushabove.
identity¶
GET /identity/users/me now returns org.workspaces sorted by name, then id
(previously unspecified for org admins). workspaces[0] is therefore stable, and
it is the same list the legacy-media fallback resolves against.
public demo page¶
GET /tvguide/ (served from CoreAPI/public/tvguide/) renders a TV guide from the
group payload — categories, grey logos, thumbnails and a Shaka preview. With your login
session it offers workspace and group dropdowns and uses the …/payload preview above, with a QUERY bar that sends category / language / channelType to the server and shows the exact request;
/tvguide/?device=<deviceId> shows the real device read instead. Throwaway; needs
internet for the Shaka CDN.
Backwards compatibility¶
Legacy flat media calls (TellyboardAdmin, capability-apps ≤ 0.7.x)¶
Old clients call /api/v1/media/… with no workspace in the path. They are routed
into the real authenticated routes by a shim (media/routes/legacy_shim.go):
X-Workspace-IDheader, else?workspaceId=query →/media/<ws>/…- neither sent →
/media/current/…, and once the caller is authenticatedcurrentis resolved to the first workspace ofGET /identity/users/me.
The shim only selects a workspace; authentication and the permission check are unchanged (no token → 401, not a member → 403, unknown id → 404).
What Tellyboard actually sends
TellyboardAdmin reads current_workspace_id from localStorage but nothing
ever writes it, so its X-Workspace-ID header is never sent. Only
getMedia() carries a ?workspaceId= (always workspaces[0]), and the shared
0.7 client puts the workspace in a list query or a request body, never a header.
Most Tellyboard media calls therefore reach the server with no workspace and rely
on the default-workspace fallback.
Not shimmed¶
Flat /api/v1/playback/*, /scheduling/* and /distribution/* calls now return
401/404. No consumer other than PlayoutAdmin was found in this workspace, and
PlayoutAdmin was moved. Tellyboard's own APIs (/playlists, /media-channels,
devices, spaces, schedules, campaigns) are different routes and are unchanged.
Links¶
Media, CDN and streamer links are unaffected: a media URL is built from the stored
bucket and key, the migration never changes keys, and Tellyboard's signage payloads
come from catalogue's own playlist_items and MEDIA_PROXY_BASE_URL. New uploads
use platform/<workspace>/… keys; old media keeps its old keys. Media and brand
URLs remain unsigned and guessable.
Implementing differently¶
| Area | Old | New |
|---|---|---|
| Choose a workspace | header or query | path segment (/media/:workspaceId/…) |
| Send the org | X-Organization-ID |
nothing — it comes from the token |
Playlist tenant |
client-supplied | derived from the workspace (<org-slug>/<workspace-slug>); a client value is ignored |
| Upload keys | client tenant/folder |
server-derived platform/<workspace>/… |
| Streamer picker | GET /distribution/:org/streamers |
GET /playback/:ws/streamers |
| Publish a group | POST /spaces/:id/channels/publish/:groupId |
POST /playback/:ws/channel-groups/:id/push (group must be published) |
| Clear a text field | not possible | send "" |
| 401 handling | per-app | refresh once, retry, then login |
Staging rollout order¶
Run the SQL before the new image — staging channels and groups have no workspace/org today and would otherwise disappear:
migration/2026-09-28_media_workspace_backfill.sqlmigration/2026-09-29_playout_scope_backfill.sqlmigration/2026-09-30_streamer_workspace_access.sqlmigration/2026-10-01_channel_brand_assets.sql
Applied on staging, 1 Oct 2026
Run by hand on NUC-A against postgres-0 (the database behind postgres-internal; not the CNPG cluster), before the new image:
2026-09-28media backfill: 185 media (245 total), 25 playlists and 4 API-created profiles → Castis "test workspace" (8c4ab36f…). 14 of 18 transcoding profiles stay system.2026-09-29playout backfill: 7 streamers, 3 caches, 1 SLB → Castis org; 47 channels and 23 groups → "test workspace"; old global unique-name indexes dropped. All consistency checks empty.- The 8
QA-TEST-*transcoding presets (and their history) were deleted by hand. The two "Multicast" presets andwwbwbwere kept. - Everything went to one workspace by decision:
jastv/media (53 rows) is not split out, so only Castis admins see it. Themalaysiaworkspace holds no data. - Not run, on purpose:
2026-09-30and2026-10-01. AutoMigrate createsstreamer_workspace_accessand the brand columns on first boot of the new image. - Backup taken first:
/tmp/coreapi-pre-backfill-20261001.sql.gzon NUC-A (fullcoreapidump, 94 MB). - CoreAPI
a7a56b1was then pushed toorigin/staging.
Each is a dry run by default (-v apply=1 to apply) and safe to re-run. Then check:
- device and space organisation ids match the token org
(
select organization_id, app_mode, count(*) from devices group by 1,2;) — the Publish sheet andpushonly reach devices of the caller's org; MEDIA_ORIGIN_BASE_URLis set (brand-asset URLs are empty without it);- local only:
Quickstartcproxy.ymllists theplaytellyorigin before the catch-all (cproxy takes the first matching origin). The IaC cproxy config already does.
Known gaps¶
- Spaces, devices and endpoints still carry a legacy org id in the local seed; until
they are backfilled the Publish sheet lists no spaces and
pushfinds no devices. provisioningdevice routes and the legacy publish routes are unauthenticated.playout_channel_metais no longer written or needed; it is only a read fallback on the legacy Tellyboard routes.- Streamer/cache/SLB
org:distribution:viewis still granted to every org role. - Tellyboard still ships capability-apps 0.7.1 and does not keep a "current workspace".