Available parameters which you can use with security token

UCDN
2017-11-28 16:34

If you have enabled protection using security token, you can define additional parameters to secure your content. The hash could be generated with the following options:

  • cdn_creation_time – when the hash was generated (unix timestamp)
  • cdn_ttl – the time for which the hash should be valid
  • cdn_net – IP from which the access will be allowed
  • cdn_bw – limit rate of the downloading speed
  • cdn_bw_fs - set the amount of data which should be served on full speed(support k,m and g for KB,MB and GB respectively)
  • cdn_cv_CUSTOM - this is custom parameter which can be configured based on your needs.(You should replace CUSTOM with any name)

With the above values, the hash that will need to be generated is:

request.uri+key+cdn_creation_time+cdn_ttl+cdn_net+cdn_bw+cdn_bw_fs+cdn_cv_CUSTOM

for example:

/example/image.jpgVerySecureKeytimestamp600192.168.0.1101024010mCUSTOM_PARAMETER

where

  • /example/image.jpg – request.uri
  • VerySecureKey – your secret key
  • timestamp – creation time for the hash, you can use time() for php or website\ http://www.epochconverter.com/
  • 600 – time to live for generated hash
  • 192.168.0.1 – the IP from which the URL can be accessed
  • 10240 – bytes per second limit rate
  • 10m - megabytes served at max speed
  • CUSTOM_PARAMETER - the value for the custom parameter

The full URL of the request will be:

http://yourdomain.com/example/image.jpg?cdn_hash=generated_hash&cdn_creation_time=timestamp&cdn_ttl=600&cdn_net=192.168.0.1&cdn_bw=10240&cdn_bw_fs=10m&cdn_cv_CUSTOM=CUSTOM_PARAMETER

You can use the following website to generate md5 hash for testing purposes:

Below you can find sample php code, for generating the required hash:

<?php

$secret_key = 'password';
$request_uri = '/path/to/video/videoname.mp4';

// Unix timestamp
$cdn_creation_time = time();

// how long the generated url will be active
$cdn_ttl = 600;

// limit access only to specified ip address or network
$cdn_net = "192.168.1.20";

// or limit access only to specified /24 network
$cdn_net = "192.168.2.0.24";

//limit download speed to
$cdn_bw = "10240" // bytes per second (10KB)

//the amount of served at maximum speed
$cdn_bw_fs = "10m" // 10 MB

//your custom parameter
$cdn_cv_CUSTOM = "CUSTOM_PARAMETER"


$hash = md5($request_uri.$secret_key.$cdn_creation_time.$cdn_ttl.$cdn_net.$cdn_bw.$cdn_bw_fs.$cdn_cv_CUSTOM);

$access_url  = 'http://cname.clientdomain.com/'.$request_uri;
$access_url .= '?cdn_hash='.$hash.'&cdn_creation_time='.$cdn_creation_time;
$access_url .= '&cdn_ttl='.$cdn_ttl.'&cdn_net='.$cdn_net.'&cdn_bw='.$cdn_bw.'&cdn_bw_fs'.$cdn_bw_fs.'&cdn_cv_CUSTOM'.$cdn_cv_CUSTOM;

?>
Tags: Additional parameters, Security token