> For the complete documentation index, see [llms.txt](https://clients.medianova.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clients.medianova.com/products/security/security-token/standard-secure-token.md). Agents can also search and read this documentation through its [MCP server](https://clients.medianova.com/~gitbook/mcp).

# Standard Secure Token

Learn how to configure Standard Secure Token and generate signed, time-limited URLs to protect individual CDN files.

Standard Secure Token restricts access to individual files using signed URLs. Each URL includes a signature and an expiration timestamp.

Your application generates the signature using a secret key. Medianova CDN validates the signature and expiration time before serving the requested file.

## How Standard Secure Token works

Standard Secure Token uses three values to generate a signature:

* **Token Key:** The secret key configured for your CDN Resource.
* **File path:** The path of the requested file.
* **Expiration time:** A Unix timestamp that determines when the URL expires.

Your application combines these values and generates an MD5 signature encoded using Base64URL without padding.

The CDN validates the signature against the requested file path and expiration time.

A valid token permits access to the requested file until it expires.

{% hint style="info" %}
Standard Secure Token protects individual files. Each file path requires its own signature. Use Secure Token v2 for directory-level signing.
{% endhint %}

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2FspdEJIP5fl9W1oZ0LdCg%2Fimage.png?alt=media&amp;token=88d09f81-671e-47fd-bf01-22ac78b85978" alt="" width="487"><figcaption><p>One token authorizes one signed file path.</p></figcaption></figure>

## Supported CDN Resource types

Standard Secure Token is available for:

| CDN Resource type | Availability |
| ----------------- | ------------ |
| Small CDN         | Supported    |
| Large CDN         | Supported    |

## Configure Standard Secure Token

Use the [Medianova Control Panel](https://cloud.medianova.com) to configure Standard Secure Token for a supported CDN Resource.

{% stepper %}
{% step %}

### Select a CDN Resource

Open the CDN Resource you want to protect in the [Medianova Control Panel](https://cloud.medianova.com).
{% endstep %}

{% step %}

### Open Security settings

Navigate to **Security → General**.
{% endstep %}

{% step %}

### Enable Security Token

Enable the **Security Token** feature.
{% endstep %}

{% step %}

### Select Standard Secure Token

Choose **Standard Secure Token** from **Token Type**.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2FoHczT0xlFIcHaxdeOoS8%2Fimage.png?alt=media&amp;token=108e5543-7a59-4afa-92b0-1c1aa0fc60b3" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure the Token Key

Enter a secret key in **Token Key**.

Store the same key securely in your application backend.
{% endstep %}

{% step %}

### Save the configuration

Click **Save** to apply the settings.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Keep your Token Key confidential. Changing the key invalidates URLs generated with the previous key.
{% endhint %}

### Generate a signed URL

Standard Secure Token uses two query parameters:

<table><thead><tr><th width="319.5">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>st</code></td><td>Base64URL-encoded MD5 signature without padding.</td></tr><tr><td><code>e</code></td><td>Expiration time as a Unix timestamp in seconds.</td></tr></tbody></table>

Both parameters are required.

### Calculate the signature

Generate the signature using the following formula:

```
st = base64url(MD5(KEY + PATH + EXPIRATION))
```

Where:

* `KEY` is the configured Token Key.
* `PATH` is the requested file path, beginning with `/`.
* `EXPIRATION` is the Unix expiration timestamp in seconds.

Concatenate the values without separators.

Encode the raw MD5 digest using Base64URL. Remove trailing `=` padding characters.

Do not encode the hexadecimal representation of the MD5 digest.

### Understand the signed URL format

A signed URL follows this structure:

```
https://<CDN_HOSTNAME>/<FILE_PATH>?st=<SIGNATURE>&e=<EXPIRATION>
```

Replace:

* `<CDN_HOSTNAME>` with your CDN hostname.
* `<FILE_PATH>` with the requested file path.
* `<SIGNATURE>` with the generated Base64URL signature.
* `<EXPIRATION>` with the Unix expiration timestamp.

The Token Key must never appear in the URL.

### Verify a signature example

Use the following test values to verify your signing implementation.

| Input           | Value                   |
| --------------- | ----------------------- |
| Token Key       | `ExampleKey2026`        |
| File path       | `/videos/sample.mp4`    |
| Expiration      | `1798761600`            |
| Expiration date | 2027-01-01 00:00:00 UTC |

The signed string is:

```
ExampleKey2026/videos/sample.mp41798761600
```

The expected signature is:

```
xxUT-FCjC3EMOW_pjtmJ1g
```

The resulting URL is:

```
https://cdn.example.com/videos/sample.mp4?st=xxUT-FCjC3EMOW_pjtmJ1g&e=1798761600
```

{% hint style="warning" %}
The example key is for testing only. Never use it to protect production content.
{% endhint %}

## Generate signed URLs with Python

The following example generates a signed URL that remains valid for one hour.

```python
import base64
import hashlib
import os
import time


def sign_url(base_url: str, path: str, key: str, ttl: int) -> str:
    expiration = int(time.time()) + ttl

    signed_data = f"{key}{path}{expiration}".encode()

    digest = hashlib.md5(signed_data).digest()

    signature = base64.urlsafe_b64encode(digest)
    signature = signature.rstrip(b"=").decode()

    return f"{base_url}{path}?st={signature}&e={expiration}"


url = sign_url(
    base_url="https://cdn.example.com",
    path="/videos/sample.mp4",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
)

print(url)
```

Set the `MN_TOKEN_KEY` environment variable to the Token Key configured in the [Medianova Control Panel](https://cloud.medianova.com).

Replace the example hostname and file path with your CDN Resource values.

{% hint style="info" %}
Generate signed URLs on your application backend. Do not expose the Token Key in browser scripts or client applications.
{% endhint %}

## Follow file path signing rules

The signed path must match the requested file path.

| Rule                      | Example                                        |
| ------------------------- | ---------------------------------------------- |
| Begin the path with `/`.  | `/videos/sample.mp4`                           |
| Exclude the hostname.     | Sign `/videos/sample.mp4`, not the full URL.   |
| Exclude query parameters. | Sign `/video.mp4` for `/video.mp4?quality=hd`. |
| Preserve letter case.     | `/Video.mp4` differs from `/video.mp4`.        |
| Use the normalized path.  | Match the path expected by the CDN.            |

For the validated Small CDN implementation, unrelated query parameters are not included in the signature.

A different path requires a new signature.

## Manage token expiration

The `e` parameter defines the expiration time as a Unix timestamp in seconds.

Calculate the timestamp using the current Unix time and the required validity period.

For example, a URL valid for one hour uses:

```
EXPIRATION = CURRENT_UNIX_TIME + 3600
```

Use a synchronized system clock when generating signatures.

After expiration, the CDN rejects new requests using the expired token.

{% hint style="info" %}
A download that starts before expiration can continue. A new request, including a resumed download or range request, requires a valid token.
{% endhint %}

## Validate signed URL requests

Test Standard Secure Token before using it in production.

For the validated Small CDN implementation:

| Condition                      | HTTP response                        |
| ------------------------------ | ------------------------------------ |
| Valid signature and expiration | Request proceeds to content delivery |
| Missing token                  | 403 Forbidden                        |
| Invalid signature              | 403 Forbidden                        |
| Expired token                  | 410 Gone                             |

A successful token validation does not guarantee an HTTP 200 response. The requested content must also be available.

## Troubleshoot Standard Secure Token

### HTTP 403 Forbidden

The CDN rejects requests with missing or invalid token information.

Check the following:

* The URL contains both `st` and `e`.
* The Token Key matches the configured key.
* The signed path matches the requested file path.
* The signature uses the raw MD5 digest.
* The signature uses Base64URL without padding.
* The expiration value has not changed after signing.

Compare your generated signature with the test example above.

### HTTP 410 Gone

For the validated Small CDN implementation, HTTP 410 indicates an expired token.

Generate a new URL with a future expiration timestamp.

Verify that your application clock is synchronized.

### Signed URLs stop working after a key change

A new Token Key takes effect immediately in the validated Small CDN implementation.

URLs signed with the previous key fail validation.

Update your application's signing key and generate new URLs.

## Security recommendations

* Store Token Keys in a secure backend environment.
* Generate signed URLs only on trusted systems.
* Use HTTPS when delivering protected content.
* Select expiration periods based on content requirements.
* Test signed URLs before enabling token enforcement.
* Coordinate Token Key changes with application updates.

{% hint style="warning" %}
Enabling Security Token can cause unsigned requests to fail. Prepare your application's signed URLs before enforcing token validation.
{% endhint %}

## Related token types

If your use case requires additional restrictions, consider:

* [**Secure Token v2**](https://clients.medianova.com/products/security/security-token/secure-token-v2.md)**:** Protect multiple files within a directory.
* [**Secure Token v2 – IP Lock**](https://clients.medianova.com/products/security/security-token/secure-token-v2-ip-lock.md)**:** Restrict access to a client IP address.
* [**Secure Token v2 – Country Lock**](https://clients.medianova.com/products/security/security-token/secure-token-v2-country-lock.md)**:** Restrict access by country.
* [**Secure Token – IP & Cookie Lock**](https://clients.medianova.com/products/security/security-token/secure-token-ip-and-cookie-lock.md)**:** Include client IP and cookie values in access validation.
* [**Parametric Secure Token**](https://clients.medianova.com/products/security/security-token/parametric-secure-token.md)**:** Use configurable signing inputs.

{% hint style="info" %}
For general configuration information, refer to the [Security Token](https://clients.medianova.com/products/security/security-token.md) page.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://clients.medianova.com/products/security/security-token/standard-secure-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
