skip to content

On a Cloudflare Stream course site where every paid lesson requires signed URLs, outsiders can still watch the weekly live class and its replays; what explains it?

level: seniorimportance: should knowfreq 16%

answer

  1. two levels of restrictions
  2. the page plays an input ID
  3. settings under recording
  4. replays inherit at recording time

basics

~20 s

Playing a Stream live input by its ID uses the input's own recording.requireSignedURLs and allowedOrigins, not any video's. Left at their defaults, the class plays without a token anywhere, and its replays inherit the same open settings.

solid answer

~40 s

The lessons are private because each video has `requireSignedURLs`, but the class page embeds the **live input ID**, and Stream then applies the input's `recording.requireSignedURLs` and `recording.allowedOrigins`, independent of video-level settings. The input was created with the defaults, `false` and any origin, so the class plays with no token on any site. Recordings take the input's recording settings by default, so every replay is public by its video ID as well. The fix is to set both fields on the input, edit each existing replay to `requireSignedURLs: true` with `allowedOrigins`, and have the class page fetch a token for the ID it plays after the enrolment check. Then verify that bare IDs fail and a token fails on another origin.

code

bash · 15 lines
bash
# Make the class input private for live viewing and for future replays
curl --request PUT \
  --header "Authorization: Bearer $API_TOKEN" \
  --data '{"recording": {"mode": "automatic", "requireSignedURLs": true, "allowedOrigins": ["courses.example.com"]}}' \
  "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/stream/live_inputs/$INPUT_ID"

# List the replays already recorded from it
curl --header "Authorization: Bearer $API_TOKEN" \
  "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/stream/live_inputs/$INPUT_ID/videos"

# Lock each existing replay by its video ID
curl --request POST \
  --header "Authorization: Bearer $API_TOKEN" \
  --data "{\"uid\": \"$VIDEO_UID\", \"requireSignedURLs\": true, \"allowedOrigins\": [\"courses.example.com\"]}" \
  "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/stream/$VIDEO_UID"

go deeper

for a junior

Recall that a Stream live input has its own recording settings, separate from any uploaded video's settings.

for a middle

Explain that viewing by input ID uses the input's recording.requireSignedURLs and allowedOrigins, and that replays take them by default.

for a senior

Diagnose from the embed ID, the input's recording object and the replay list, fix input and replays separately, and verify bare IDs and foreign origins fail.

for a principal

Make access settings part of provisioning for every video and live input, with a recurring audit, rather than trusting each team to set them by hand.

## The symptom A course platform on Cloudflare Stream has done the on-demand part right: every lesson is uploaded through a direct creator upload with `requiresignedurls`, and the backend signs a short-lived token for each enrolled student. Yet a non-student who copies the weekly live class's embed code can watch the class live, and the class's replays play for anyone who has their IDs. Nothing is broken; the live path is governed by **different settings** than the lesson videos. ## Where the live path takes its settings Stream keeps **two levels** of playback restrictions, and the class touches both: | What the player loads | Which `requireSignedURLs` and `allowedOrigins` apply | |---|---| | A lesson's **video ID** | The video's own settings | | The class's **live input ID** | The live input's `recording.requireSignedURLs` and `recording.allowedOrigins`, **independent of** any video-level setting | | A replay's **video ID** | The replay video's own settings, which the input's recording settings give it **by default** when it is recorded | The class page sensibly embeds the live input ID, so it always shows the current broadcast. But the input was created with the defaults: `recording.requireSignedURLs` is `false` and `recording.allowedOrigins` is `null` (any site). Viewing by input ID therefore needs no token and works on any domain. Each replay recorded from that input inherited the same open settings, so replays are public by ID too. The upload pipeline's `requiresignedurls` never touched any of this, because live recordings do not pass through it. ## Diagnosing it 1. **Find which ID the class page plays.** Open the embed: a `customer-<CODE>.cloudflarestream.com/<ID>/iframe` URL with the live input's ID means input-level rules apply. 2. **Read the input.** Fetch the live input and check its `recording` object: `requireSignedURLs` and `allowedOrigins`. 3. **List the replays.** `GET .../live_inputs/{input_id}/videos` returns one video per broadcast; check each one's `requireSignedURLs` and `allowedOrigins`. 4. **Check the broadcast in progress.** During a class, the input's `lifecycle` endpoint returns the active `videoUID`; that video is the replay being recorded, and its own settings show what the replay will carry. 5. **Reproduce from outside.** Load the bare input ID's `/iframe` and HLS manifest from a browser with no session and from another origin. If either plays, the gap is confirmed. ## Fixing it - **Make the input private.** `PUT .../live_inputs/{input_id}` with `recording.requireSignedURLs: true` and `recording.allowedOrigins` listing your course domains. Future replays then start private by default. - **Lock existing replays one by one.** The docs describe the input's setting as a default applied to videos recorded from it, so check each existing replay's own `requireSignedURLs` and edit it to `true` with `allowedOrigins` rather than assuming it changed. - **Issue tokens for the live page too.** The token replaces the ID in the URL, so the class page now asks your backend for a token for the ID it plays, after the same enrolment check the lessons use. - **Keep the token's reach short.** An `exp` covering the class, plus `allowedOrigins`, limits how far a forwarded link travels; a token is a bearer credential until it expires. - **Check related paths.** Replays with MP4 downloads need tokens with `downloadable: true`; a public `poster` thumbnail also needs a signed URL once the video is private. ## Verifying the fix 1. The bare live input ID and a replay's bare video ID no longer play, in the player or through the manifest. 2. A token minted after the enrolment check plays on your domain. 3. The same token in a page on another origin is refused because of `allowedOrigins`. 4. After the next class, the new replay shows `requireSignedURLs: true` without any manual edit. ## Why this is a Stream-specific trap Token issuance is the same for lessons and classes; the trap is that Stream stores access settings **per video and per live input**, and a live input's settings only seed the videos it records. A review of "do all our videos require signed URLs" that only lists uploaded lessons misses both the input and its recordings. Put the input's `recording` settings into the same provisioning code that creates lessons, so no live input is ever created with defaults.

  • Why not embed each class's video ID instead, so the lesson rules apply?
    Each broadcast gets a new video ID when it starts, so a page tied to the weekly class would need updating every week and could not show 'not started' between classes. Keeping the input ID and making the input private gives a stable embed with the same protection.
  • After the fix, how do you stop the gap recurring when a new course adds its own live input?
    Create live inputs only through provisioning code that always sets `recording.requireSignedURLs` and `recording.allowedOrigins`, and add a periodic check that lists inputs and videos and flags any with `requireSignedURLs` false.

  • Video-level requireSignedURLs protects anything played through the live input ID.
  • Replays automatically follow the lesson upload settings.
  • allowedOrigins alone makes the class private to enrolled students.
  • Live classes cannot use signed URLs at all.