Last update:2025-03-24 10:22:49
This document provides a detailed explanation of Authentication Mode A and B, along with instructions on how to use them.
Modes A and B allow you to embed authentication information directly into the URL path for CDN. This method helps secure your content by ensuring that only authorized users can access it.
The URL format for Authentication Mode A is as follows:
http://domain/<time>/<key>/uri
The URL format for Authentication Mode B is as follows:
http://domain/<key>/<time>/uri
In these URL structures, <key>
and <time>
are the authentication parameters. The CDN edge server verifies this information to determine whether to serve the requested content based on the verification results. Please note that the order of <key>
and <time>
in Modes A and B is fixed and cannot be altered.
The symbols
<>
in the URL structures indicate the positions of the authentication parameters. These symbols are not part of the actual URL.
The authentication URL consists of the following fields:
Field | Description |
---|---|
domain | This is the domain name you have configured for CDN. |
time | The time field represents the timestamp indicating when the URL was generated. The CDN edge server uses this timestamp to determine the validity of the URL. If the current time exceeds the URL’s validity period, the content will not be served. The time value must adhere to one of the supported timestamp formats. Failure to do so will result in authentication failure. Refer to the Time Format section for details on supported formats. |
key | The key field contains the encrypted signature used for authentication verification. This signature is generated by combining the timestamp (time ), a secret encryption key (ourkey ), and the requested URI (uri ). For detailed information on how the signature is calculated, refer to the Signature Calculation Parameters sections. |
uri | The actual path of the URL requesting content from the CDN. For instance, if the original request URL is http://cdnetworks.com/browse/index.html , then the uri would be /browse/index.html . If the request URL includes query parameters (e.g., /browse/index.html?user=123 ), the uri should only contain the path of the requested object, excluding the query string |
When a CDN edge server receives a request with embedded authentication parameters, it performs the following steps:
Timestamp Validation: The server first checks if the timestamp (time
) in the URL has expired.
time
+ valid duration
< current time
, the URL is considered expired. Access is denied, and an HTTP 403 Forbidden
error is returned.time
+ valid duration
≥ current time
, the URL is considered valid.Signature Verification: If the timestamp is valid, the CDN edge server calculates the expected authentication signature based on the configured encryption key (ourkey
), the timestamp (time
), and the requested URI (uri
). It then compares this calculated signature with the key
provided in the URL.
403 Forbidden
error is returned.In the Authentication Modes settings, choose Mode A or Mode B as needed. The following sections explain the purpose and method for each configuration field.
The Authentication Key ($ourkey
) is a secret string that is used to generate the authentication signature (key
) in the URL. This key is shared only between you and the CDN servers, providing an extra layer of security by making it difficult for unauthorized users to generate valid authentication parameters.
$ourkey
values in your CDN console, separated by semicolons .When constructing an authentication URL, the time
field must adhere to one of the following supported formats:
Timestamp Format | Description |
---|---|
Decimal Unix Timestamp | E.g., 1586338211 represents April 8, 2020, 17:30:11 UTC. |
Hexadecimal Unix Timestamp | E.g., 5e8e2463 represents 1586338211 in hexadecimal. |
Millisecond-level Unix Timestamp | E.g., 1586338211000 represents the same point in time. |
YYYYMMDDHHMMSS | E.g., 20200408173011 represents April 8, 2020, 17:30:11. |
YYYYMMDDHHMM | E.g., 202004081730 represents April 8, 2020, at 17:30. |
The authentication signature (key
) is generated using an encryption algorithm. By default, the MD5 algorithm is used. For enhanced security, you can request a different encryption algorithm by contacting our technical support team.
To generate the authentication signature (key
), you will typically use the following parameters:
time
: The timestamp.ourkey
: Your secret authentication key.uri
: The requested content path.When constructing the string to be encrypted, you can choose to include one or more of these parameters and specify their order of combination.
Example: If you configure the combination order as $uri$ourkey$time
, the unencrypted string will be formed by concatenating the uri
, followed by the $ourkey
, and then the time
.
http://cdnetworks.com/browse/index.html
, with an $ourkey
of cdnetworks
, and a time
of 202405131620
, the generated unencrypted string would be /browse/index.htmlcdnetworks202405131620
. This string would then be passed through the configured encryption algorithm (e.g., MD5) to generate the final signature (key
).You can configure the validity period for the authentication information using one of the following methods:
time
) in the URL.
60
means the authentication information will be valid for one minute after the time specified in the URL.-60,60
means the authentication information will be valid from one minute before to one minute after the timestamp.-
) to disable validity period checks.The option to interchange the positions of key
and time
in the request URL is not applicable to Authentication Modes A and B. In these modes, the positions of key
and time
are fixed and must follow the specified order.
To ensure your authentication configuration is correct and to avoid potential disruptions to your online services, it is highly recommended to initially deploy the configuration to a test environment. Once you have verified its accuracy, you can then implement it in your live production environment.
Additionally, you can utilize the Timestamp Anti-Hotlinking Calculator available in your CDN console. This tool allows you to generate URL authentication parameters and quickly verify your configuration.