IO River python library for generating URL signatures
Project description
url-signer-python
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
conditiondictionary 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e68c5279dbb0b8d9b55d3592a918904e7ae4f2e7062f862f7d2f17a4e809ff0
|
|
| MD5 |
fc5b5bbc65d271e5fd9046b636ee1dd2
|
|
| BLAKE2b-256 |
c46f5d3efafee0820aa4a0e92962d838dd8304db31970d84822c1ae7fc5a48c0
|
File details
Details for the file url_signer_python-0.4.0-py3-none-any.whl.
File metadata
- Download URL: url_signer_python-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd3f5f27a90d0a4b3e8ac85ad1113b30ebda1a4a775122b0df65f13708f77aff
|
|
| MD5 |
f1d29a8d72309d517dac7b784d0e4dc3
|
|
| BLAKE2b-256 |
cbef60b2a233a3f8f1695dd48d4d01b1b9dd0def3f99198f0ad77988685d97b7
|