#cloud-front #aws #signed-url #signed-cookie

cloudfront_sign

Utility module for AWS CloudFront to generate signed URLs and cookies

5 unstable releases

0.3.0 Feb 25, 2024
0.2.1 Nov 13, 2022
0.2.0 Nov 13, 2022
0.1.2 Mar 27, 2021
0.1.1 Mar 17, 2021

#6 in #cloud-front

Download history 587/week @ 2024-06-14 524/week @ 2024-06-21 343/week @ 2024-06-28 403/week @ 2024-07-05 333/week @ 2024-07-12 264/week @ 2024-07-19 371/week @ 2024-07-26 340/week @ 2024-08-02 312/week @ 2024-08-09 439/week @ 2024-08-16 493/week @ 2024-08-23 515/week @ 2024-08-30 535/week @ 2024-09-06 353/week @ 2024-09-13 397/week @ 2024-09-20 272/week @ 2024-09-27

1,680 downloads per month
Used in 2 crates (via cnctd_aws)

MIT license

15KB
204 lines

AWS CloudFront Sign Utility

Generating signed URLs for CloudFront links is a little more tricky than for S3. It's because signature generation for S3 URLs is handled a bit differently than CloudFront URLs. The Rusoto library is in maintenance mode and not accepting more features. Therefore we created this simple utility library to sign CloudFront URLs in Rust.

Examples

Getting signed cookies.

use std::fs;
use cloudfront_sign::*;
let private_key = fs::read_to_string("tests/data/private_key.pem").unwrap();
let options = SignedOptions {
    key_pair_id: String::from("SOMEKEYPAIRID"),
    private_key: private_key,
    ..Default::default()
};
let cookies = get_signed_cookie("https://example.com", &options).unwrap();

Getting signed URLS.

use std::fs;
use cloudfront_sign::*;
let private_key = fs::read_to_string("tests/data/private_key.pem").unwrap();
let options = SignedOptions {
    key_pair_id: String::from("SOMEKEYPAIRID"),
    private_key: private_key,
    ..Default::default()
};
let signed_url = get_signed_url("https://example.com", &options).unwrap();

Dependencies

~5MB
~98K SLoC