3 releases

0.1.2 Sep 13, 2023
0.1.1 Sep 12, 2023
0.1.0 Sep 12, 2023

#275 in Authentication

32 downloads per month

MIT license

26KB
438 lines

RustEdgeRc

EdgeRc is a Rust library designed to sign Akamai HTTP requests.

Crates.io MIT licensed Build Status

Content Table

Installation

Add the following dependency in your project Cargo.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
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.

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.

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.

Dependencies

~4.5–6.5MB
~116K SLoC