#aws #cloudfront #signed-url #signed-cookie

cloudfront_sign

Utility module for AWS CloudFront to generate signed URLs and cookies

4 releases

0.2.1 Nov 13, 2022
0.2.0 Nov 13, 2022
0.1.2 Mar 27, 2021
0.1.1 Mar 17, 2021

#270 in Cryptography

Download history 2/week @ 2022-08-09 10/week @ 2022-08-16 4/week @ 2022-08-23 9/week @ 2022-08-30 10/week @ 2022-09-06 18/week @ 2022-09-13 13/week @ 2022-09-20 17/week @ 2022-09-27 6/week @ 2022-10-04 8/week @ 2022-10-11 13/week @ 2022-10-18 12/week @ 2022-10-25 26/week @ 2022-11-01 51/week @ 2022-11-08 16/week @ 2022-11-15 21/week @ 2022-11-22

115 downloads per month

MIT license

14KB
200 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.

Requirements

OpenSSL need to be installed.

# macOS
$ brew install openssl@1.1

# Arch Linux
$ sudo pacman -S pkg-config openssl

# Debian and Ubuntu
$ sudo apt-get install pkg-config libssl-dev

# Fedora
$ sudo dnf install pkg-config openssl-devel

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

~1.5–2.2MB
~49K SLoC