Skip to main content

cloudfront-signed-cookies

PyPI - Version PyPI - Python Version Hatch project Code style: black


IF YOU'RE INTERESTED, go checkout my Medium blog post for a deeper dive on what this package is doing and some usage examples.

Table of Contents

Installation

pip install cloudfront-signed-cookies

Usage

from cloudfront_signed_cookies.signer import Signer
import os

def main():
    """
    Method #1
    Allow the signer to read your key from a file
    """
    signer: Signer = Signer(
        cloudfront_key_id="K36X4X2EO997HM",
        private_key="./certs/private_key.pem",
    )

    """
    Method #2
    Alternatively you can pass the raw contents of the key in from
    something such as an environment variable, for container (Docker)
    based usage
    """
    signer: Signer = Signer(
        cloudfront_key_id="K36X4X2EO997HM",
        private_key=os.environ.get("PRIVATE_KEY")
    )

    cookies: dict = signer.generate_cookies(
        Policy={
            "Statement": [
                {
                    "Resource": "https://domain.com/somefile.txt",
                    "Condition": {
                        "DateLessThan": {
                            "AWS:EpochTime": 1000
                        }
                    },
                }
            ]
        },
        SecondsBeforeExpires=360,
    )
    print(cookies)

main()
"""
{'CloudFront-Policy': 'eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoic29tZV91cmwiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjEwMDB9fX1dfQ__', 'CloudFront-Signature': 'EZHxOEAhaKB3e-XUAGI5xJdDQaWKuW-h6m8c4UYcFBkaA3Fh4~DygZUcYCj-S-qtUdrl46i8vp4RuvtDz4sL9GEVGGDniZc8iDVDqHmfllMFK-90Ge-C9lQ-umsqm-IQzaFVDS3WMbi5iAsRDpdUGfAk43ergTMvjhd~xxpVCCHZxW8uBt11kAjEoqdbMm6eVC32F-QB2HJndN9mm4d~dizvW~XjVt69fA0YjY7-TiIVKAO5ajnDaBl17AsLolLfLYl6NGBJjadLjueMCWM2DP5lXYce8RF2qW02wg8bNmth3ykPoVHFT-tgIgetOcDFDCFSnTkXXhUy3mu2wPzdKQ__', 'CloudFront-Key-Pair-Id': K36X4X2EO997HM'}
"""

License

cloudfront-signed-cookies is distributed under the terms of the MIT license.

Metadata

Release files for cloudfront-signed-cookies 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloudfront-signed-cookies 1.2
File Size Uploaded Provenance Actions
cloudfront_signed_cookies-1.2.tar.gz 8.6 kB Without provenance Details for cloudfront_signed_cookies-1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cloudfront-signed-cookies 1.2
File Interpreter ABI Platform Actions
cloudfront_signed_cookies-1.2-py3-none-any.whl Python 3 none any Details for cloudfront_signed_cookies-1.2-py3-none-any.whl

Total release size: 18.2 kB

Release files / cloudfront_signed_cookies-1.2.tar.gz

Download URL cloudfront_signed_cookies-1.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
96018fe9916757effc0ad2526cd729ca235b3434742c29fa48ef82a4610b26aa
BLAKE2b-256 checksum
How to use checksums
08f59bf8528e65bd92aaa25bcee9fde70c70296634d2d7744759a73f3ec90e59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / cloudfront_signed_cookies-1.2-py3-none-any.whl

Download URL cloudfront_signed_cookies-1.2-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69a0b33b69ef69911da701617d0f7461b4f95ef828f1ff877a9c3102f2ae5a43
BLAKE2b-256 checksum
How to use checksums
7298c6f19ec1443378d37d77c61a9af8ad4828b34301f5fb63f15ef92fe7f2ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for cloudfront-signed-cookies 1.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page