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 url-signer-python import feature

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"
}

singer = 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 = singer.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.3.0.tar.gz (7.1 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.3.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for url_signer_python-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5ebc8914029d36d827422127139173df476d4748326a1b3cbcb0de962b0d738f
MD5 43b2083c32b2e263886ea8f00d45118b
BLAKE2b-256 67770eacb49e9d6eae92a6fcee698fd1da24b692a45aa29be0bd7017f6be485b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for url_signer_python-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afba153fb713d640e225e2608860fba3739004d55c2e456cbbbb98f5cf321f47
MD5 9ed1a23cd670798658421a96aaf85753
BLAKE2b-256 2ed3d8f66e71a8f9f66456608e8b2c10636e9371a69fa3f11621a2b086710e64

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