Auth Token 2.0
Protect CDN-delivered content using signed, time-limited URLs that restrict access to authorized viewers.
Auth Token 2.0 allows you to control access to protected CDN content by requiring a valid cryptographic token in each request URL. Tokens are generated by your application and validated at the Medianova edge before content is delivered.
Auth Token 2.0 supports both query string and path-based token placement, making it suitable for protecting video streams, private downloads, subscriber-only content, and other resources that require controlled access.
How Auth Token 2.0 Works
Auth Token 2.0 uses HMAC-SHA256 signatures to verify that a request is authorized.
Your application generates a token using a shared secret key, an expiration time, and the path being authorized.
The token is included in the request URL, either as a query string parameter or as part of the URL path.
The viewer requests the protected content through Medianova CDN.
The CDN validates the token signature, expiration time, authorized path, and optional IP restriction.
If validation succeeds, the content is delivered. Otherwise, the request returns
403 Forbidden.
Token validation is performed at the edge without storing individual tokens. This allows consistent validation across Medianova Points of Presence (POPs).
Before You Begin
Before generating tokens:
Contact Medianova Support to enable Auth Token 2.0 for your hostname.
Specify the paths that require protection, such as
/protected/*.Obtain the shared secret key associated with your Auth Token 2.0 configuration.
Confirm whether your hostname uses query string mode or path mode.
Ensure your application can generate HMAC-SHA256 signatures.
The shared secret key is a 64-character hexadecimal string representing 32 bytes.
Token Format
An Auth Token 2.0 consists of name=value fields separated by the tilde character (~), followed by an HMAC signature.
Example:
exp=1893456000~acl=/videos/movie/*~hmac=<signature>
Supported Token Parameters
Parameter
Required
Description
ip
No
Restricts token usage to a specific IPv4 or IPv6 address.
st
No
Token start time, expressed as a Unix timestamp in seconds.
exp
Yes
Token expiration time, expressed as a Unix timestamp in seconds.
acl
Conditional
Path or wildcard pattern authorized by the token. Use acl or url.
id
No
Session or user identifier included in the signature.
data
No
Additional application-defined data included in the signature.
hmac
Yes
HMAC-SHA256 signature represented as lowercase hexadecimal. Must be the final field.
When using url instead of acl, the url field is included in the signature calculation but is not included in the transmitted token.
Signature Generation
To generate the signature:
Collect the applicable token parameters.
Arrange the fields in this order:
ip,st,exp,acl,id,data.Omit optional fields that are not used.
Join the fields using
~.If using
urlinstead ofacl, appendurl=<path>to the signing string.Decode the hexadecimal shared key into raw bytes.
Calculate the HMAC-SHA256 signature.
Convert the result to lowercase hexadecimal and append it as
hmac.
Example signing string:
exp=1893456000~acl=/videos/movie/*
Generate and Use a Auth Token 2.0
Define the Protected Path
Choose the file or directory that the token should authorize.
Single protected file
url
/protected/movie.mp4
HLS or DASH stream
acl
/protected/movie/*
Protected directory
acl
/downloads/user42/*
The * wildcard matches characters including /, allowing one token to authorize multiple resources within a directory.
Add the Token to the Request URL
Auth Token 2.0 supports two URL placement modes.
Query String Mode
The token is passed as a query string parameter.
Query string mode is suitable for individual files and protected downloads.
Path Mode
The token is included directly in the URL path.
Path mode is recommended for HLS and DASH streaming, where manifests reference additional media segments.
Verify Token Validation
After Auth Token 2.0 has been enabled, test access to a protected resource.
Before testing, replace cdn.example.com with your CDN hostname and <hmac> with a valid HMAC-SHA256 signature generated using your shared secret key.
Ensure that the token has not expired, the ACL matches the requested resource, and the token placement mode matches your hostname configuration.
The examples below assume that Auth Token 2.0 has been enabled in query string mode for the /protected/video/* path.
Request with a valid token:
For an existing, accessible resource with a valid token, the expected response is 200 OK. Depending on the resource and origin configuration, another successful HTTP status may be returned.
Request without a token:
Expected result:
403 Forbidden
Also verify that an expired token is rejected.
Code Examples
The following examples demonstrate how to generate Auth Token 2.0s using HMAC-SHA256.
Replace the example key and paths with the values associated with your configuration.
Test Vector
Use the following values to verify that your implementation generates the expected signature.
Input
Value
Key (hex)
00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
Signed fields
exp=1893456000~acl=/videos/movie/*
Expected HMAC
f7804edd4d367aa03ce249b14a5233d038e6a55d6055b263152162255f25b02a
Python
Set the MEDIANOVA_TOKEN_KEY environment variable to your Auth Token 2.0 shared key before running this example. The key must be a 64-character hexadecimal string.
Linux/macOS
Windows PowerShell
Node.js
PHP
Bash and OpenSSL
HLS and DASH Streaming
For HLS and DASH streaming, use path mode with an ACL that covers the complete stream directory.
Example:
/protected/movie/*
This allows the manifest and its associated segments to use the same token.
When configuring token expiration:
Set
expto cover the expected viewing session, including a reasonable buffer.Refresh tokens before expiration for long-running or live streams.
Avoid IP-bound tokens for viewers who frequently switch between mobile and Wi-Fi networks.
Generate tokens on your application server for each viewer session.
If a token expires while playback is in progress, subsequent segment requests return 403 Forbidden.
Caching Behavior
Auth Token 2.0 validation is performed at the Medianova edge before protected content is delivered.
The token is removed before cache lookup or origin forwarding.
As a result:
The origin does not receive the token.
Different valid tokens can access the same cached content.
The token is not included in the cache key.
Token validation also applies to cache hits.
This allows protected resources to benefit from CDN caching without bypassing token validation.
Key Rotation
Auth Token 2.0 supports key rotation using two simultaneously active keys.
To rotate a key:
Contact Medianova Support to add the new shared key.
Update your application to generate tokens using the new key.
Allow previously generated tokens to expire.
Contact Medianova Support to retire the old key.
Troubleshooting
Auth Token 2.0 rejects invalid requests with 403 Forbidden.
The response does not disclose which validation check failed.
All requests return 403
Incorrect signing order or key encoding
Compare your signature against the test vector.
Fresh tokens return 403
Incorrect server time
Synchronize your server clock using NTP.
Manifest works but segments fail
ACL does not cover segment paths
Use a wildcard covering the stream directory.
Only some viewers receive 403
IP restriction does not match
Review or remove the ip parameter.
Token works in query mode but not path mode
Incorrect token placement mode
Confirm the configured mode with Support.
ACL does not match
URL encoding or path normalization differs
Verify the normalized request path.
Playback stops during a session
Token expired
Extend the validity period or refresh the token.
Security Best Practices
Store shared keys only in trusted server-side environments.
Generate tokens on your application server, never in client-side code.
Use the shortest practical token expiration period.
Limit token access to the required files or directories.
Avoid overly broad ACL patterns such as
/*unless necessary.Use the optional
idfield to associate tokens with viewer sessions for troubleshooting.Consider IP restrictions only when viewer IP addresses are expected to remain stable.
Rotate keys if they may have been exposed.
Need Help?
Contact Medianova Support if you need to:
Enable Auth Token 2.0 for your hostname.
Configure protected paths.
Obtain or rotate your shared secret key.
Confirm the supported token placement mode.
Investigate token validation failures.
When reporting a problem, include your CDN hostname and an example failing URL. Remove the HMAC signature and any sensitive information before sharing the URL.
Last updated
Was this helpful?