# RustEdgeRc EdgeRc is a Rust library designed to sign Akamai HTTP requests. [![Crates.io][crates-badge]][crates-url] [![MIT licensed][mit-badge]][mit-url] ![Build Status][actions-badge] [crates-badge]: https://img.shields.io/crates/v/edgerc.svg [crates-url]: https://crates.io/crates/edgerc [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg [mit-url]: https://bitbucket.org/millohcs/edgerc__lib/src/main/LICENSE [actions-badge]: https://img.shields.io/bitbucket/pipelines/millohcs/edgerc__lib/main ## Content Table - [Installation](#installation) - [Usage](#usage) - [Contribution](#contribution) - [Licence](#licence) ## Installation Add the following dependency in your project `Cargo.toml`: ```toml [dependencies] edgerc = "0.1.0" ``` ### Usage **Prepare configuration**: 1. Read .edgerc file to string. 2. Create an EdgeRC signer builder 3. Get an EdgeRC signer for de selected section ```rust let section = "default"; let edgerc_string: String = std::fs::read_to_string("~/.edgerc")?; let edge_signer = Credentials::build_signer(edgerc_string) .get_by_section(section.to_string()).unwrap(); ``` **Create a signature** 1. Prepare an EdgeRCRequest with the request properties 2. Obtain the se signed authorization header passing the request and the signer 3. Use the header in the http request by placing it as the value of the Authorization header ***Important:*** Make sure your http client is not modifying either the body or headers. Otherwise will incur into a bad signed request. ```rust let edge_request = EdgeRCRequest { method: EdgeRCHttpMethods::POST, path: format!("/ccu/v3/invalidate/url/{network}/"), query_strings: None, canonical_headers: None, body_hash: EdgeRCSigner::encode_body(body.to_string(), None), }; let signed_authorization_header = signer.get_authorization_header_value(&edge_request); ``` ## License This project is licensed under the [MIT license]. [MIT license]: https://bitbucket.org/millohcs/edgerc__lib/src/main/LICENSE ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this [EdgeRC lib] by you, shall be licensed as MIT, without any additional terms or conditions.