signed-urls
Introduction
A signed URL is a URL that grants temporary, limited access to a resource, such as a file in cloud storage. It includes an expiration date and a digital signature in its query string, which authenticates the request and ensures the URL hasn't been altered. This allows users without direct credentials to perform a specific action, like downloading a file, for a limited time.
How signed URLs work?
- A server creates a standard URL and adds parameters like an expiration time.
- The server generates a digital signature using a secret key and appends it to the URL.
- The signed URL is shared with the user.
- When the user accesses the URL, the resource server verifies the signature and checks the expiration time.
- If the signature is valid and the URL hasn't expired, access to the resource is granted.
Use cases
- Secure file downloads and uploads allowing temporary access.
- Granting temporary access to private resources without sharing credentials.
- Time-limited access to APIs for third-party applications.
signed-urls package
The signed-urls package provides a simple way to generate and verify signed URLs.
Installation
pip install signed-urls
Basic usage
from signed_urls import sign_url, verify_signed_url
method = "GET"
secret_key = "Top-Secret-Key"
url = "https://example.com/resource/1?owner=alice"
hashing_algorithm = "SHA256"
sign_format = "base64"
# Generate a signed URL
signed_url = sign_url(
method=method,
url=url,
secret_key=secret_key,
ttl=300,
algorithm=hashing_algorithm,
sign_format=sign_format
)
# Verify the signed URL
is_valid = verify_signed_url(
method=method,
signed_url=signed_url,
secret_key=secret_key,
algorithm=hashing_algorithm,
sign_format=sign_format
)
print(f"Is the signed URL valid? {is_valid}")
Supported hashing algorithms
- SHA256
- SHA512
- BLAKE2B
- BLAKE2S
Supported sign formats
- base64: creates signature as base64 ASCII string
- hex: creates signature as hexadecimal string
Metadata
Release files for signed-urls 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| signed_urls-0.1.0.tar.gz | 10.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| signed_urls-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.8 kB
Release files / signed_urls-0.1.0.tar.gz
| Download URL | signed_urls-0.1.0.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
689002a31338ee21137ee0eb8f6aeb8c0fde0c7e90d9440c92acf04309e42ea5
|
|
BLAKE2b-256 checksum How to use checksums |
b57f66d7faef3c6d1a28e14af531a91fc96d6871adbf72924a8e69db6632a952
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Release files / signed_urls-0.1.0-py3-none-any.whl
| Download URL | signed_urls-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4a9d13e26cc20e83f5248c1b9228c818cfc027007632083214f3cb2831bf948
|
|
BLAKE2b-256 checksum How to use checksums |
7360505c20512dd4466447813b5713279a2b32fff3933fcd6aca7136c54b3ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Security for signed-urls 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.