Skip to main content

IO River python library for generating URL signatures

Project description

url-signer-python

PyPI version Python version Build Status

Overview

url-signer-python is a Python library designed to generate signatures for URLs. These signatures can be used by the IO River service with Signed-URLs enabled to secure access to content. The library generates signatures for all CDN providers associated with the service.


Installation

To install url-signer-python, you can use pip:

pip install url-signer-python

Alternatively, you can clone the repository and install it manually:

git clone https://github.com/ioriver/url-signer-python.git
cd url-signer-python
pip install .

Usage

Below is some example to help you get started:

Step 1: Create URL Signer

from ioriver.url_signer import UrlSigner

private_key = "YourPrivateKey"
encryption_key = "YourEncryptionKey"

# use the provider key information from your service
providers_key_info = {
    "cloudfront_key_id": "1234",
    "fastly_key_id": "5678"
}

signer = UrlSigner(private_key, encryption_key, providers_key_info)

Step 2: Generate Signature

# the policy to be signed
policy = {
    "resources": "https://test.example.com/streams/*",
    "condition": {
        "end_time": 1733356800
    }
}

# generate signature for all CDNs
signature = signer.generate_url_signature(policy)

API Reference

UrlSigner Constructor

Parameters

  • private_key (string): The private key for signing the URL.
  • encryption_key (string): The encryption key for signing the URL.
  • providers_key_info (object): Information about the keys deployed within the CDN providers (copied from your service).

generate_url_signature(policy)

Attributes for policy

  • resources (required): A string specifying the URL or URL pattern the policy applies to.

  • condition (required):
    A dictionary containing conditions for the policy.

    • end_time (required):
      An integer specifying the UNIX timestamp when the signature will expire.

    Additional optional attributes in the condition dictionary include:

    • start_time:
      An integer specifying the UNIX timestamp when the signature becomes valid. Default: None.

Requirements

This library requires:

  • Python 3.7+
  • Dependencies listed in requirements.txt.

To install dependencies manually:

pip install -r requirements.txt

Testing

pytest

Support

If you encounter any issues, please open an issue on GitHub or contact us at support@ioriver.io.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

url_signer_python-0.4.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

url_signer_python-0.4.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file url_signer_python-0.4.0.tar.gz.

File metadata

  • Download URL: url_signer_python-0.4.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for url_signer_python-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5e68c5279dbb0b8d9b55d3592a918904e7ae4f2e7062f862f7d2f17a4e809ff0
MD5 fc5b5bbc65d271e5fd9046b636ee1dd2
BLAKE2b-256 c46f5d3efafee0820aa4a0e92962d838dd8304db31970d84822c1ae7fc5a48c0

See more details on using hashes here.

File details

Details for the file url_signer_python-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for url_signer_python-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3f5f27a90d0a4b3e8ac85ad1113b30ebda1a4a775122b0df65f13708f77aff
MD5 f1d29a8d72309d517dac7b784d0e4dc3
BLAKE2b-256 cbef60b2a233a3f8f1695dd48d4d01b1b9dd0def3f99198f0ad77988685d97b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page