How does Gcore protect video content?
Gcore has several methods of protecting video content:- Protected temporary links with secure token
- Country access policy (geo-restrictions)
- Referrer validation
- AES-128 encryption
What are protected temporary links?
Protected temporary links are generated using the CDN-resource Secure Token feature, which allows configuring access with tokenized URLs. When using this option, you add a special character set to every URL. Check out the examples below with the special characters highlighted in bold. At Gcore, we call these special characters Secure Tokens. VOD:- Public: https://demo-public.gvideo.io/videos/2675_pG8TfmKx2LU2qs/master.m3u8
- Protected: https://demo-protected.gvideo.io/videos/2675_pG8TfmKx2LU2qs/rI1224fiE3USCa8qYnMuGQ/1861919999/master.m3u8
- Public: https://demo-public.gvideo.io/cmaf/2675_19146/master.m3u8
- Protected: https://demo-protected.gvideo.io/cmaf/2675_19146/9y9nJqRofJQw-DbX2LDgYw/1861919999/master.m3u8
- HTTP 2xx response code, if the hash key is valid and unexpired
- HTTP 403 Forbidden response, if the hash key is invalid
- HTTP 410 Gone response, if the hash key is valid but expired
CDN resources and scope of restrictions
Video content hosted via the Video Streaming is viewed and delivered through our CDN, so by default your account has only one hidden CDN resource in the format ******.gvideo.io. The restriction policies, such as the Secure Token for links protection, apply specifically to CDN resources because a CDN resource covers all video content at once. This means you don’t need to create rules and make permissions for each video separately—it is enough to create and apply permissions only once to the CDN resource. Note: Your account can have several CDN resources leading to the same content (origin). These CDN resources can be with different access policies. So you can combine open access on one CDN resource, and private access on another one, etc. For example we have 2 demo domains for IP-binding and generic:- For generic secure token use without IP-binding: https://demo-protected.gvideo.io/
- For IP-binded secure token: https://demo-protected-ip.gvideo.io/
How to enable the secure token feature?
To enable the Secure Token feature and start protecting your links, please check out the CDN page how to activate a secure token for CDN-resource.To enable IP-based secure tokens, turn on the “Add client IP to token” option. Disable this option if IP binding is not required.
Secure token for HLS/DASH
Secure token – protected temporary links have the following format:videos
– for VOD,cmaf|mpegts
– for LIVE{client_id}
is your account ID{video_id}
is the identifier of the video or live stream{token}
is the MD5 hash of the video and other attributes{expiration}
is a Unix timestamp (in seconds) that defines until when the link remains valid
https://domain.com/videos/{client_id}_{video_slug}/{token}/{expiration}/
manifest.m3u8https://domain.com/videos/{client_id}_{video_slug}/{token}/{expiration}/
segment-1-svod720n-v1-a1.tshttps://domain.com/videos/{client_id}_{video_slug}/{token}/{expiration}/
720.mp4
https://domain.com/cmaf/{client_id}_{stream_id}/{token}/{expiration}/
master.m3u8https://domain.com/cmaf/{client_id}_{stream_id}/{token}/{expiration}/
index.mpdhttps://domain.com/cmaf/{client_id}_{stream_id}/{token}/{expiration}/
004chunk-stream4-10000000-05213.m4s?part=4
Advanced secure token for MP4
A regular secure token for HLS/DASH from above protects the entire video entity. When distributing MP4 files separately from ABR, use an MP4 advanced secure token as an additional query parameter. This restricts access to the specific MP4 rendition and prevents unauthorized MP4 distribution.Advanced secure token for MP4 cannot be combined with generic secure token for HLS/DASH. In case of combination the secure token for HLS/DASH will have priority to resolve an accees.
{token}
is the MD5 hash of the MP4 file path and other options{expiration}
is a Unix timestamp (in seconds) that defines until when the link remains valid
A note on the expiration time
The expiration time must be at least equal to the duration of the original video or the expected duration of the live playback. When the signed URL expires, URLs will no longer be played, even if playback has already begun. Because video expiration time is integrated into the URL described above, new chunks will no longer be given by the relative path. Your app also needs to handle cases where a user starts to play a video, then leaves your app for a long time, and then comes back later and tries to play the video again. You will probably need to detect this behavior and reacquire the new signed URL to make sure playback can start. To handle both cases, ensure you set the expiration far enough into the future that users won’t experience playback interruptions.How to create protected links with the secure token
Create secure token for HLS/DASH
Pattern to generate token:- Tokens without user ip:
- Tokens with user ip:
Parameter | Required | Description |
---|---|---|
client_id | yes | URL of the MP4 file |
video_id | yes | Video_Slug or Stream_ID identifier |
secret | yes | Secret phrase |
expires | yes | Expiration time (Unix timestamp, UTC) |
user_ip | optional | Client IP address. Required only if token was generated with IP binding |
- Python
- Go
Create advanced secure token for MP4
The MP4 advanced secure token is generated from the full MP4 URL. You can optionally bind MP4 speed limit to the token by including thespeed
and buffer
parameters. This ensures that download rate limits cannot be bypassed – if a user tampers with these values, the request will return 403 Forbidden.
If no speed limit is required, set both speed
and buffer
to an empty string when generating the token.
Pattern to generate token:
- Tokens without user ip:
- Tokens with user ip:
Parameter | Required | Description |
---|---|---|
uri | yes | Path from MP4 file URL |
secret | yes | Secret phrase |
expires | yes | Expiration time (Unix timestamp, UTC) |
speed | optional | Download speed limit in bytes/sec. Use an empty string if not required |
buffer | optional | Buffer size in bytes for rate limiting. Use an empty string if not required |
user_ip | optional | Client IP address. Required only if token was generated with IP binding |
MySecr3tStr1ng
Without user ip:
- Python
- Go