edgerc

Crates.ioedgerc
lib.rsedgerc
version0.1.2
sourcesrc
created_at2023-09-12 03:58:05.564524
updated_at2023-09-13 16:20:20.126475
descriptionA standard Akamai edgerc signer
homepage
repositoryhttps://bitbucket.org/millohcs/edgerc__lib
max_upload_size
id970424
size27,303
Patricio A. Di Muzio (dimuziop)

documentation

README

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.

Commit count: 0

cargo fmt