Crates.io | cloudfront_sign |
lib.rs | cloudfront_sign |
version | 0.3.0 |
source | src |
created_at | 2021-03-17 18:07:27.266171 |
updated_at | 2024-02-25 19:42:06.258204 |
description | Utility module for AWS CloudFront to generate signed URLs and cookies |
homepage | https://www.promaton.com |
repository | https://github.com/promaton/cloudfront-sign-rs |
max_upload_size | |
id | 370233 |
size | 18,938 |
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.
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();