Skip to main content

Access Control for SVOD Platforms

Edge Key & Access Control for SVOD Platforms

This guide covers video access management for platforms with multiple content tiers: free, subscription, and purchase/rental.

Core Concept

AntCDN doesn’t know who your users are. It doesn’t have accounts, subscriptions, or payment info.

Your backend handles:

  • User authentication
  • Subscription/purchase verification
  • JWT token generation

AntCDN validates: “Is this JWT valid for this edge key?”

This separation gives you full control over your business logic.


Edge Key Strategy

Recommendation: One private edge key per video, created at upload time.

const assetId = await uploadVideo(file);
const edgeKey = await createEdgeKey(assetId, {
label: "primary",
isPrivate: true // Always private for paid platforms
});
await db.videos.insert({
asset_id: assetId,
edge_key: edgeKey,
content_tier: "subscription" // or "free", "purchase"
});

The Access Flow

User clicks "Play"
┌─────────────────┐
│ Your Backend │ 1. Authenticate user
│ │ 2. Check access (subscription? purchased?)
│ │ 3. Generate JWT token
│ │ 4. Return playback URL
└────────┬────────┘
┌─────────────────┐
│ AntCDN │ Validates JWT → Serves video
└─────────────────┘

Database Schema

CREATE TABLE videos (
id UUID PRIMARY KEY,
title TEXT NOT NULL,
asset_id TEXT NOT NULL,
edge_key TEXT NOT NULL,
content_tier TEXT NOT NULL, -- 'free', 'subscription', 'purchase'
price_cents INTEGER,
rental_hours INTEGER
);
CREATE TABLE purchases (
id UUID PRIMARY KEY,
user_id UUID REFERENCES users(id),
video_id UUID REFERENCES videos(id),
purchase_type TEXT NOT NULL, -- 'buy' or 'rent'
expires_at TIMESTAMP -- NULL for purchases, set for rentals
);

Backend Authorization


JWT Token Generation

import jwt from 'jsonwebtoken';
const SIGNING_KEY = process.env.ANTCDN_SIGNING_KEY;
function generateVideoToken(userId, edgeKey) {
return jwt.sign(
{
sub: edgeKey,
uid: userId,
exp: Math.floor(Date.now() / 1000) + (4 * 60 * 60) // 4 hours
},
SIGNING_KEY,
{ algorithm: 'HS256' }
);
}

Token Lifetime Recommendations:

Content TypeToken Lifetime
Free24 hours
Subscription4-8 hours
Rentalmin(rental_expires, 4 hours)
Purchase4-8 hours

Common Questions

Should I create multiple edge keys per video?

No. One private edge key per video is sufficient. The JWT controls access.

How does AntCDN know who my user is?

It doesn’t need to. AntCDN only validates:

  1. Is the JWT signature valid?
  2. Is it for this edge key? (sub claim)
  3. Is it unexpired?

What if a user shares the playback URL?

JWTs expire (e.g., 4 hours). Short-term sharing is possible, long-term is not.

For higher security:

  • Shorter token lifetimes
  • Concurrent stream limits (track on your backend)

How do I handle free content?

Two options:

Option A: Public edge keys for free content (no JWT needed)

Option B: Private edge keys, but always grant access in your backend

Option B is better for consistency and analytics.


Summary

You ControlAntCDN Controls
User authenticationVideo storage
Subscription/purchase logicCDN delivery
Token issuanceJWT validation
Business rulesEdge key → video mapping

Your backend is the gatekeeper. AntCDN is the delivery truck.