TL;DR
- Playback authorization answers whether this account may watch this asset now. A signed playback credential can carry a short-lived, narrowly scoped authorization to the CDN.
- Protect every media object in the playback graph: master playlist, media playlist, segments, subtitles, encryption keys, and any license request. Securing only the first manifest leaves direct segment URLs exposed.
- For HLS with many files, signed cookies or a custom policy can be easier than minting a separate signed URL for every segment. Verify the CDN’s exact behavior and origin access configuration.
- CDN access control and DRM solve different problems. A signed URL or cookie controls delivery; FairPlay or Widevine protects encrypted media keys and playback on supported devices.
- Keep tokens short-lived, bind them to an asset and audience, avoid unnecessary personal data, and design a renewal and revocation strategy around actual stream behavior.
Model the full playback authorization path
A paid video is not one file. An HLS or DASH session may request a master manifest, a selected bitrate playlist, many short media segments, subtitles, thumbnails, encryption keys, and a DRM license. A viewer who receives a public manifest with public segment URLs can share those URLs regardless of whether the website’s play button checked a subscription.
Build the path around separate decisions. The application authenticates the viewer and checks the catalog entitlement, subscription state, geographic rights, device policy, and playback limits. It then mints a capability that allows delivery for a specific asset and short time period. The content delivery network (CDN) validates that capability before serving each protected object. If the asset is encrypted with digital rights management (DRM), a license service separately decides whether the player may receive the required content key.
These checks do not prevent every form of copying. A viewer who can play a video may record the screen or capture output on a compromised device. DRM can impose platform-level protections and key policies, while watermarking and abuse controls help with downstream investigation. Set expectations about the threat model instead of describing signed tokens as “piracy proof.”
Choose a credential that covers the HLS object tree
Signed URLs for individual resources
A signed URL includes a signature and validity policy for a resource. It can work for a single downloadable file or a player that can rewrite every playlist reference with its own signature. HLS creates a fan-out of dependent requests, so verify that the master playlist, nested playlists, segments, subtitles, encryption-key endpoint, and byte-range requests all carry valid authorization.
Signing only the master playlist does not automatically sign relative segment paths inside it. A player may resolve those paths and request them without the original query string. Rewriting manifests introduces parser, caching, and token-propagation complexity. If signed URLs are used, test the actual player implementation across bitrate switches, retries, seeking, and playlist refreshes.
Signed cookies for multiple files
A signed cookie can authorize a set of files under a path or policy while leaving media URLs unchanged. This often fits a video package containing many HLS resources. Amazon CloudFront specifically describes signed cookies for access to multiple restricted files such as all files for an HLS video. The application sends the required cookie values before the viewer requests media, and CloudFront validates the signature and policy for requests that use them. CloudFront signed URL or cookie decision guide · CloudFront signed cookies
For browser playback, scope cookies to the narrowest host and path that the CDN supports. Use secure transport and avoid broad parent-domain cookie scope. For native applications, confirm how the player sends cookies on every request, including cross-origin and key requests. If the player cannot attach cookies consistently, a player-supported header or signed URL flow may be required.
Custom edge tokens
A custom token can carry claims such as sub, asset_id, aud, exp, and a policy version. An edge function verifies the signature, expiration, audience, and requested path before returning a cached object. Prefer asymmetric signatures when possible: the entitlement service keeps the private signing key and CDN workers receive only a public verification key. If the edge must hold a shared HMAC secret, treat every deployment and debug surface that can expose it as a credential boundary.
Token claims should be minimal. Do not embed email addresses, payment details, or an entire entitlement record in a URL. A token is a bearer capability: anyone who obtains it can use the rights it encodes until it expires or a revocation check rejects it. Avoid query strings when they are likely to be copied to browser history, analytics, referrers, support logs, or proxy access logs. Short expiry limits exposure but does not erase copies already made.
Issue a capability only after an entitlement check
The application should treat token issuance as an authorization operation, not as a convenience endpoint that accepts an arbitrary asset ID. Verify that the authenticated principal can watch the asset, that the subscription or purchase is active, and that regional or account rules permit playback. Apply concurrency limits and device rules before issuing a token if those are part of the product contract.
Bind the capability to the smallest useful scope. A token can authorize a single asset’s CDN path, a specific audience such as video-playback, and a short expiry. Include nbf only if clock synchronization and edge behavior are known. Include a unique token ID only when you have a design for revocation or replay analysis; storing a nonce without checking it adds no enforcement.
Illustrative token claims might look like this:
{
"sub": "account_opaque_id",
"asset_id": "movie_483",
"aud": "cdn-playback",
"entitlement_version": 12,
"exp": 1795200000
}
This is a shape, not a complete JSON Web Token (JWT) policy. Use a maintained JOSE library, pin allowed algorithms, validate issuer and audience, reject unsigned tokens, and keep signing keys in a managed key service. Choose token duration based on player refresh intervals, segment length, live versus on-demand behavior, and revocation needs. There is no universal “five-minute” value that fits every stream.
When token refresh is needed, the player asks the authenticated application for a new capability. The refresh endpoint repeats the entitlement check; it must not accept an old playback token as proof that the account still has access. Rate-limit issuance and detect unusual playback fan-out without logging the token itself.
Keep CDN delivery and DRM license authorization separate
A signed CDN credential controls whether the edge may deliver an object. DRM controls whether a compatible player may acquire and use the content decryption key. These layers complement each other. A signed cookie around an unencrypted HLS playlist prevents casual direct access only while the cookie remains valid. It does not encrypt the media segment after delivery.
Apple’s FairPlay Streaming protects HLS delivery on Apple platforms through encrypted content and a key-delivery process. Google Widevine supports encrypted media and a license service; its documentation states that a Widevine client does not communicate directly with the Widevine License Service. In both systems, the player’s license request should pass through an authenticated and authorized service path appropriate to the platform. Apple FairPlay Streaming · Google Widevine DRM overview
For DRM playback, authorize both the media request and the license request. The license service should verify the user or playback session, asset, requested key IDs, device and output policy where supported, and entitlement freshness. A valid CDN token should not automatically grant a DRM license for every asset. Likewise, a DRM license should not make the underlying manifest public if business rules require authenticated delivery.
HLS AES-128 encryption with an application-controlled key URI is not equivalent to a complete DRM system. Protect the key endpoint, use TLS, control key rotation, and understand client storage. If premium content requires platform DRM or output controls, use the DRM platform’s approved packaging and license flow rather than inventing a private cipher scheme.
Make the origin inaccessible around the CDN gate
If the media origin is a public object-store URL, an attacker can bypass CDN authorization and request the object directly. Restrict origin access to the CDN using the provider’s supported origin access identity or control. For custom origins, allow traffic from the CDN and validate origin authentication independently. Keep storage bucket listings and manifests private.
Configure the edge authorization check to run before it returns a cache hit. Test this explicitly: a cached segment must still be denied to a request with an expired, missing, tampered, or wrong-asset token. Authorization state and cache state are separate. CDN providers have different signed-cookie, signed-URL, cache-key, and edge-function semantics. Follow the exact provider guide and build a staging test around your behavior. CloudFront recommends restricting direct origin access so viewers cannot bypass its signed-URL or cookie restrictions. CloudFront private-content restrictions
Do not key the cached media object by the viewer token unless there is a specific reason. Doing so can fragment cache entries and reduce hit ratio. Instead, use a stable object path for immutable media and enforce the viewer’s authorization at the edge. Confirm that the CDN does not forward sensitive cookies or authorization headers to an origin that does not need them.
Playlist caching differs by content type. Video segments are typically immutable and cacheable for long periods. A live playlist changes frequently and may need a much shorter time-to-live. Key endpoints and DRM licenses are sensitive and should follow their own cache policy. Ensure that no cache configuration can reuse one viewer’s personalized manifest for another viewer.
Plan for expiry, revocation, and playback continuity
A short-lived capability reduces the window in which a copied token can be reused, but it can also interrupt playback if the player requests another segment after expiration. Renew before expiry with a small overlap. For a live stream, account for long sessions, playlist reloads, clock skew, and network recovery. If the entitlement is revoked during playback, decide how quickly subsequent segment and license requests should stop.
Immediate revocation requires an online decision or a revocation mechanism that propagates to the edge. A purely stateless token remains valid until its expiry. Possible designs include a short-lived token plus frequent refresh, an entitlement-version check at the edge, a denylist for exceptional revocations, or a session service. Each option has different availability, cache, and latency costs. Do not advertise instant account revocation if the actual system only stops new playback after the token expires.
IP binding is optional and can reduce sharing in some environments, but mobile clients, VPNs, carrier NAT, and network transitions can change the observed address during a session. Apply IP policies only where the product and device experience support them. Device identifiers are also sensitive and should be minimized and retained carefully.
For concurrent stream limits, a token by itself is not a counter. Track active sessions in a stateful service with a lease, heartbeat, or player session ID. Reconcile abandoned sessions after network loss, and avoid rejecting a legitimate reconnect while an old lease is still expiring. Keep entitlement decisions and session counting separate from the CDN’s signature check.
Test the complete HLS and DRM request graph
Build a test manifest that includes variant playlists, media segments, subtitles, byte-range requests, encryption keys, and a license request if DRM is enabled. Use the same player SDK and CDN behavior that production will use. Test a valid session, expired token, malformed signature, wrong asset, changed entitlement version, missing cookie on a segment, direct-origin request, and a token replay from another account.
Test playback transitions as well as single requests: bitrate switch, seek, pause and resume, reconnect after a mobile network change, token renewal, and an entitlement revoked mid-session. Make sure one denied resource produces a controlled player error rather than an infinite retry loop.
Observe denial reason codes, asset ID, CDN request ID, entitlement version, and token key ID. Never log the raw token, signed cookie, DRM license challenge, authorization header, or content key. Alert on repeated token failures and suspicious request fan-out, but avoid putting user-specific high-cardinality fields into general metric labels.
Rotate signing keys by adding the new public verification key before issuing new tokens, waiting at least the maximum token lifetime, then removing the old key. Keep an emergency key-revocation path and test propagation to every edge location. For long-running streams, the refresh path can move active sessions to the new key without extending old tokens indefinitely.
Frequently asked questions
Is a signed playback URL enough to protect premium video?
It can control access to the URL while the signature is valid, but it does not encrypt media or stop copying after authorized playback. Cover every manifest and segment request, restrict direct origin access, and use DRM when the content policy requires encrypted delivery and platform license controls.
Should I use a signed URL or a signed cookie for HLS?
Use a signed cookie or policy when one authorization should cover many files under a video path and the player reliably sends cookies on every request. Use signed URLs when the client cannot send cookies or authorization is per object. Test variant playlists, segments, keys, retries, and range requests with the chosen player and CDN.
Does DRM replace CDN authorization?
No. CDN authorization governs delivery of manifests and segments. DRM governs key acquisition and use by a compatible player. Protect both paths when required, and ensure a CDN token cannot authorize unrelated DRM licenses or assets.
Can I revoke a stateless playback token immediately?
Not without an additional revocation check. A signed token remains valid until its expiration unless the edge checks an entitlement version, denylist, session state, or another revocable source. Short expiry bounds the exposure window but may affect continuous playback and requires a secure refresh path.
Make each layer enforce one clear rule
Use the entitlement service to decide who may start playback, the CDN to gate every media object, and the DRM license service to control decryption keys where required. Bind signed capabilities to an asset, audience, and expiry. Keep origin storage private and exercise the full player request graph before launch.
Security improves when the token flow is scoped and observable without turning bearer tokens into log data. If you are designing a paid video platform or auditing HLS and DRM access paths, talk with our engineering team about entitlement checks, CDN configuration, and player renewal behavior.
