> 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/streaming-secure-token-ip-lock.md). Agents can also search and read this documentation through its [MCP server](https://clients.medianova.com/~gitbook/mcp).

# Streaming Secure Token / IP Lock

Learn how to configure Streaming Secure Token – IP Lock and generate IP-bound signed URLs for streaming content.

Streaming Secure Token – IP Lock protects live and video-on-demand (VOD) content using signed URLs tied to the viewer's IP address.

Each signature includes an expiration timestamp, the Token Key, and the viewer's IP address. You can also include the stream directory and selected query parameter values.

A signed URL becomes invalid when the viewer accesses it from a different IP address.

## How Streaming Secure Token – IP Lock works

Your application generates signed URLs for authorized viewers. Medianova CDN validates each request using the configured Token Key and the IP address detected at the edge.

The validation process follows four stages:

1. **Token generation:** Your backend signs the expiration time, Token Key, viewer IP address, and optional values.
2. **Content request:** The viewer requests a signed playlist, segment, or media file.
3. **Token validation:** Medianova CDN recalculates the signature using the request's IP address.
4. **Request handling:** The CDN processes valid requests and rejects invalid or expired tokens.

The Token Key and signed IP address do not appear as separate URL parameters.

{% hint style="info" %}
IP Lock limits URL sharing across networks. It does not authenticate individual users. Viewers sharing the same public IP address may be able to reuse a valid URL.
{% endhint %}

### Understand access restrictions

<table><thead><tr><th width="232.5">Restriction</th><th>Behavior</th></tr></thead><tbody><tr><td>IP address</td><td>The request must originate from the signed IP address.</td></tr><tr><td>Expiration</td><td>The token must remain valid when the request starts.</td></tr><tr><td>Directory</td><td>Optional. Limits the token to the signed streaming directory.</td></tr><tr><td>Query parameters</td><td>Optional. Protects selected parameter values against modification.</td></tr></tbody></table>

A viewer who changes networks during playback may need a new signed URL.

## Supported CDN Resource types

Streaming Secure Token – IP Lock is available for the following CDN Resource types:

| CDN Resource type | Availability  |
| ----------------- | ------------- |
| Small CDN         | Not supported |
| Large CDN         | Not supported |
| Large Streaming   | Supported     |
| Streaming / VOD   | Supported     |
| Dynamic CDN       | Not supported |

Large Streaming supports playlists and segments, with public-path exceptions configured through Page Rules.

Streaming / VOD supports protected playlist and segment requests.

## Understand signing options

Streaming Secure Token – IP Lock supports directory signing, selected query parameters, and two URL formats.

<table><thead><tr><th width="181.5">Option</th><th>Behavior</th></tr></thead><tbody><tr><td><strong>Token URI</strong></td><td>Includes the stream directory in the signature when enabled.</td></tr><tr><td><strong>Query parameters</strong></td><td>Includes selected query parameter values in the signature.</td></tr><tr><td><strong>Third-party format</strong></td><td>Uses a single <code>hdnts</code> parameter instead of separate <code>st</code> and <code>e</code> parameters.</td></tr></tbody></table>

#### Understand Token URI behavior

<table><thead><tr><th width="100.5">Token URI</th><th width="313">Signed values</th><th>Access scope</th></tr></thead><tbody><tr><td>Enabled</td><td>Expiration, key, IP address, directory, optional query values</td><td>Files within the signed directory scope</td></tr><tr><td>Disabled</td><td>Expiration, key, IP address, optional query values</td><td>All paths within the CDN Resource, from the signed IP address</td></tr></tbody></table>

{% hint style="warning" %}
Disabling Token URI removes directory restrictions. A valid token can authorize other paths within the CDN Resource from the same IP address until expiration.
{% endhint %}

## Configure Streaming Secure Token – IP Lock

Use the [Medianova Control Panel](https://cloud.medianova.com) to configure this token type.

{% stepper %}
{% step %}

### Select a CDN Resource

Open a supported CDN Resource in the [Medianova Control Panel](https://cloud.medianova.com).
{% endstep %}

{% step %}

### Open Security settings

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

{% step %}

### Enable Security Token

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

{% step %}

### Select Streaming Secure Token – IP Lock

Choose **Streaming Secure Token – IP Lock** from **Token Type**.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2F8twuIF56hWSu6bis7OiJ%2Fimage.png?alt=media&amp;token=b184721b-7a67-4ab5-96cd-df253390204f" alt=""><figcaption><p>Configure Streaming Secure Token – IP Lock</p></figcaption></figure>
{% endstep %}

{% step %}

### Configure the Token Key

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

Use at least 32 randomly generated alphanumeric characters.

You can generate a 32-character hexadecimal key with:

```bash
openssl rand -hex 16
```

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

{% step %}

### Configure Token URI

Enable **Token URI** to include the stream directory in the signature.

Disable it only when path-independent access is required.
{% endstep %}

{% step %}

### Configure query parameters

Specify the query parameter names whose values must be included in the signature.

Leave the list empty when additional parameter protection is unnecessary.
{% endstep %}

{% step %}

### Select the token format

Use the standard format or enable the third-party format when your integration requires `hdnts`.
{% endstep %}

{% step %}

### Save the configuration

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

{% hint style="warning" %}
Changing the Token Key invalidates previously generated URLs immediately. Keep the key in a secure secret store.
{% endhint %}

## Generate a standard signed URL

The standard format uses two required query parameters.

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

### Calculate the signature

When Token URI is enabled, use:

```
st = base64url(MD5(e + " " + KEY + " " + IP + " " + DIRECTORY))
```

Where:

* `e` is the expiration timestamp.
* `KEY` is the configured Token Key.
* `IP` is the viewer's IP address as detected by the CDN.
* `DIRECTORY` is the normalized streaming directory.

Use exactly one space between each value.

When Token URI is disabled, use:

```
st = base64url(MD5(e + " " + KEY + " " + IP))
```

Do not add a trailing space when the directory is excluded.

The signature uses the raw 16-byte MD5 digest encoded with Base64URL. Remove trailing `=` padding characters.

### Verify the directory-based example

Use these values to test your implementation:

| Input           | Value                         |
| --------------- | ----------------------------- |
| Token Key       | `ExampleKey2026`              |
| File path       | `/live/stream1/playlist.m3u8` |
| Directory       | `/live/stream1/`              |
| Viewer IP       | `203.0.113.10`                |
| Expiration      | `1798761600`                  |
| Expiration date | 2027-01-01 00:00:00 UTC       |

The signed string is:

```
1798761600 ExampleKey2026 203.0.113.10 /live/stream1/
```

The expected signature is:

```
kmIWwp_kwKkW4voUdliW1Q
```

The resulting URL is:

```
https://cdn.example.com/live/stream1/playlist.m3u8?st=kmIWwp_kwKkW4voUdliW1Q&e=1798761600
```

The signature can authorize supported requests within `/live/stream1/` from the signed IP address.

### Verify the path-independent example

When Token URI is disabled, use:

```
1798761600 ExampleKey2026 203.0.113.10
```

The expected signature is:

```
oqtrmtv19UzsDr790A-P9g
```

The resulting URL is:

```
https://cdn.example.com/live/stream1/playlist.m3u8?st=oqtrmtv19UzsDr790A-P9g&e=1798761600
```

This token is not restricted to a directory, but it remains bound to the signed IP address.

{% hint style="warning" %}
The example key and IP address are for testing only. Never use example credentials in production.
{% endhint %}

## Generate a third-party signed URL

The third-party format uses a single `hdnts` query parameter.

Its value contains the expiration timestamp and signature, separated by `~`.

Use this structure:

```
hdnts=e=<EXPIRATION>~st=<SIGNATURE>
```

The signing formula remains unchanged.

### Verify the third-party example

Using the directory-based test values, the signature is:

```
kmIWwp_kwKkW4voUdliW1Q
```

The resulting URL is:

```
https://cdn.example.com/live/stream1/playlist.m3u8?hdnts=e=1798761600~st=kmIWwp_kwKkW4voUdliW1Q
```

Do not percent-encode the internal `=` or `~` separators.

The third-party format uses UTC for expiration validation.

{% hint style="info" %}
The standard and third-party formats use the same signature algorithm. Only the token parameter structure and certain validation behaviors differ.
{% endhint %}

## Protect selected query parameters

Streaming Secure Token – IP Lock can include selected query parameter values in the signature.

For example, configure `userId` to prevent viewers from modifying its value without invalidating the token.

### Calculate a signature with query parameters

Append each configured parameter value after the existing signed values.

Separate each value with one space.

For example, when Token URI is enabled and `userId=42`:

```
SIGNED_STRING =
e + " " + KEY + " " + IP + " " + DIRECTORY + " " + USER_ID
```

The corresponding standard URL has this structure:

```
https://cdn.example.com/live/stream1/playlist.m3u8?st=<SIGNATURE>&e=<EXPIRATION>&userId=42
```

For the third-party format, include the parameter inside `hdnts`:

```
https://cdn.example.com/live/stream1/playlist.m3u8?hdnts=e=<EXPIRATION>~st=<SIGNATURE>~userId=42
```

#### Follow parameter naming rules

| Format      | Allowed parameter name characters      |
| ----------- | -------------------------------------- |
| Standard    | Letters, digits, and underscores (`_`) |
| Third-party | Letters and digits only                |

Preserve the configured parameter order when generating the signature.

Every configured query parameter must appear inside `hdnts` when using the third-party format.

{% hint style="warning" %}
The source implementation reports HTTP 500 when a required configured parameter is missing from `hdnts`. Verify this behavior with Video Engineering before relying on it operationally.
{% endhint %}

## Generate signed URLs with Python

The following example supports both token formats, optional directory signing, and selected query parameters.

It reads the Token Key from an environment variable and generates a URL valid for one hour.

```python
import base64
import hashlib
import os
import time
from urllib.parse import urlencode


def sign_url(
    base_url: str,
    path: str,
    key: str,
    ttl: int,
    viewer_ip: str,
    token_uri: bool = True,
    third_party: bool = False,
    signed_params: dict[str, str] | None = None,
) -> str:
    expiration = int(time.time()) + ttl
    signed_params = signed_params or {}

    signed_parts = [
        str(expiration),
        key,
        viewer_ip,
    ]

    if token_uri:
        directory = path[:path.rfind("/") + 1]

        # Normalize keyframe paths.
        directory = directory.replace(
            "/keyframes/",
            "/",
        )

        signed_parts.append(directory)

    signed_parts.extend(signed_params.values())

    signed_data = " ".join(signed_parts)

    digest = hashlib.md5(
        signed_data.encode("utf-8")
    ).digest()

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

    if third_party:
        hdnts = f"e={expiration}~st={signature}"

        for name, value in signed_params.items():
            if not name.isalnum():
                raise ValueError(
                    "Third-party parameter names "
                    "must be alphanumeric."
                )

            hdnts += f"~{name}={value}"

        return f"{base_url}{path}?hdnts={hdnts}"

    params = {
        "st": signature,
        "e": str(expiration),
        **signed_params,
    }

    return (
        f"{base_url}{path}?"
        f"{urlencode(params)}"
    )


url = sign_url(
    base_url="https://cdn.example.com",
    path="/live/stream1/playlist.m3u8",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    viewer_ip="203.0.113.10",
    token_uri=True,
)

print(url)
```

Set `MN_TOKEN_KEY` to the Token Key configured in the Medianova Control Panel.

Replace the example hostname, stream path, and viewer IP address with your actual values.

Set `token_uri` and `third_party` to match the CDN Resource configuration.

To sign an additional query parameter, use:

```python
url = sign_url(
    base_url="https://cdn.example.com",
    path="/live/stream1/playlist.m3u8",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    viewer_ip="203.0.113.10",
    token_uri=True,
    signed_params={"userId": "42"},
)
```

For the third-party format, set `third_party=True`.

{% hint style="warning" %}
Generate signed URLs on a trusted backend. Never expose the Token Key in player code, browser scripts, or mobile applications.
{% endhint %}

## Follow IP address rules

The signed IP address must match the address Medianova CDN detects for the request.

Use the viewer's public IP address, not the IP address of your application server or load balancer.

If your application uses a reverse proxy, obtain the viewer's IP address from a trusted proxy configuration.

Do not trust arbitrary client-supplied forwarding headers.

### Handle IP address changes

A signature becomes invalid when the viewer's IP address changes.

Common causes include:

* Switching between Wi-Fi and mobile data.
* Connecting or disconnecting a VPN.
* Changing mobile network gateways.
* Accessing your application over IPv4 and the CDN over IPv6.

Generate a new signed URL when the viewer's IP address changes.

### Handle IPv6 addresses

Use a consistent compressed IPv6 representation.

For example:

```
2001:db8::1
```

The application must sign the same address representation used by the CDN.

{% hint style="warning" %}
IP Lock may interrupt playback on networks where the viewer's public IP address changes frequently.
{% endhint %}

## Follow streaming directory rules

When Token URI is enabled, sign the directory containing the requested stream file.

The directory ends at the final `/` before the file name.

For example:

| Requested path                | Signed directory |
| ----------------------------- | ---------------- |
| `/live/stream1/playlist.m3u8` | `/live/stream1/` |
| `/live/stream1/segment001.ts` | `/live/stream1/` |
| `/live/stream2/playlist.m3u8` | `/live/stream2/` |

A token for `/live/stream1/` does not automatically authorize `/live/stream2/`.

### Handle HLS requests

For HLS, the same directory signature can authorize a playlist and its segments within the signed directory.

Each request must include valid token parameters.

### Handle DASH and Smooth Streaming requests

For DASH and Smooth Streaming, the source implementation checks segment requests against the directory one level above their own.

Keep segments in a subdirectory of the manifest directory.

For example:

```
/live/stream1/manifest.mpd
/live/stream1/video/segment001.m4s
```

Sign:

```
/live/stream1/
```

### Handle keyframe paths

The source implementation removes `/keyframes` components from the signed directory.

For example:

```
Requested directory:
/live/keyframes/stream1/

Signed directory:
/live/stream1/
```

Use the normalized directory when generating signatures.

## Manage token expiration

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

For example, a one-hour token uses:

```
EXPIRATION = CURRENT_UNIX_TIME + 3600
```

Use a synchronized system clock when generating signatures.

### Choose an expiration period

Streaming sessions may generate multiple playlist and segment requests.

Each request requires a valid token.

Use an expiration period appropriate for the expected viewing session, or implement token renewal.

A response started before expiration can complete. Seeking, resuming, and new range requests require valid tokens.

### Understand Token Timezone

The standard format supports a Token Timezone setting.

The source implementation evaluates expiration using the configured UTC offset.

The third-party format always uses UTC.

Use UTC unless your integration specifically requires another setting.

## Deploy Streaming Secure Token – IP Lock safely

Prepare signed URL generation before enabling token enforcement.

{% stepper %}
{% step %}

### Generate a Token Key

Create a secure key and store it in your application's secret management system.
{% endstep %}

{% step %}

### Implement IP-bound signing

Add the expiration timestamp, Token Key, viewer IP address, and optional values to your signing implementation.
{% endstep %}

{% step %}

### Validate the signing implementation

Compare the generated signature with the worked example on this page.
{% endstep %}

{% step %}

### Update your streaming player

Configure the player to request signed playlists and media segments.
{% endstep %}

{% step %}

### Verify IP address handling

Confirm that the application signs the IP address detected by Medianova CDN.
{% endstep %}

{% step %}

### Configure public path exceptions

Create Page Rules for content that must remain publicly accessible, where supported.
{% endstep %}

{% step %}

### Enable Streaming Secure Token – IP Lock

Apply the prepared configuration in the Medianova Control Panel.
{% endstep %}

{% step %}

### Test protected playback

Verify valid, invalid, expired, and IP-mismatched requests.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Enabling Security Token immediately rejects unsigned protected requests. Deploy signed URLs before enforcing token validation.
{% endhint %}

## Validate protected requests

The source technical guide documents the following responses:

| Condition                               | Expected response                    |
| --------------------------------------- | ------------------------------------ |
| Valid signature and expiration          | Request proceeds to content delivery |
| Missing signature                       | 403 Forbidden                        |
| Invalid signature                       | 403 Forbidden                        |
| Viewer IP address mismatch              | 403 Forbidden                        |
| Expired token                           | 410 Gone                             |
| Missing configured parameter in `hdnts` | 500 Internal Server Error            |

In the third-party format, expiration is checked before the signature. From the expiration timestamp onward, an expired request can return HTTP 410 even when its signature is invalid.

A successful token validation does not guarantee HTTP 200. Content availability and other CDN settings still affect the final response.

## Troubleshoot Streaming Secure Token – IP Lock

### HTTP 403 Forbidden

Check the following:

* The Token Key matches the configured key.
* The signed IP address matches the address detected by the CDN.
* The token format matches the CDN Resource configuration.
* The Token URI setting matches the signing method.
* The signed directory matches the requested path.
* Configured query parameters appear in the correct order.
* The signed string uses exactly one space between values.
* The signature uses the raw MD5 digest.
* Base64URL encoding excludes `=` padding.
* The URL has not been modified or redirected.

Compare your generated signature with the worked example:

```
kmIWwp_kwKkW4voUdliW1Q
```

### HTTP 410 Gone

The source implementation uses HTTP 410 for expired tokens.

Generate a new signed URL with a future expiration timestamp.

Verify the application clock and Token Timezone configuration.

### Playback fails after changing networks

The viewer's public IP address may have changed.

Generate a new signed URL using the current IP address.

### A playlist works but segments fail

Check whether segment requests include valid token parameters.

Verify the signed directory and the streaming protocol's directory rules.

For DASH and Smooth Streaming, check the parent-directory behavior.

### The third-party token fails

Verify the `hdnts` structure:

```
hdnts=e=<EXPIRATION>~st=<SIGNATURE>
```

Ensure every configured query parameter appears inside `hdnts`.

Do not percent-encode its internal `=` and `~` separators.

### Signed URLs stop working after a key change

Changing the Token Key invalidates previously generated URLs immediately.

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

## Security recommendations

* Store the Token Key in a secure backend environment.
* Use trusted sources to determine client IP addresses.
* Enable Token URI when directory restrictions are required.
* Use HTTPS when delivering streaming content.
* Keep token expiration periods appropriate for viewing sessions.
* Protect sensitive query parameter values by including them in the signature.
* Test playback on IPv4, IPv6, mobile networks, and VPN connections.
* Monitor HTTP 403 and 410 responses after enabling enforcement.
* Coordinate Token Key changes with application and player updates.

{% hint style="warning" %}
IP-bound signed URLs are temporary access credentials. They reduce cross-network sharing but do not replace application authentication.
{% endhint %}

## Related token types

For different access requirements, consider:

* [**Streaming Secure Token**](https://clients.medianova.com/products/security/security-token/streaming-secure-token.md)**:** Protect live and VOD content without IP binding.
* [**Secure Token v2 – IP Lock**](https://clients.medianova.com/products/security/security-token/secure-token-v2-ip-lock.md)**:** Restrict supported CDN content 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 signed URLs to a country.
* [**Auth Token 2.0**](https://clients.medianova.com/products/security/security-token/auth-token-2-0.md)**:** Use EdgeAuth-compatible token validation for supported streaming integrations.

{% hint style="info" %}
For general feature configuration, 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/streaming-secure-token-ip-lock.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.
