mauth-client

Crates.iomauth-client
lib.rsmauth-client
version0.4.0
sourcesrc
created_at2021-01-19 19:45:01.774872
updated_at2024-06-11 19:15:07.040225
descriptionSign requests and validate responses using the Medidata MAuth protocol
homepagehttps://github.com/mdsol/mauth-client-rust
repositoryhttps://github.com/mdsol/mauth-client-rust
max_upload_size
id344108
size67,277
(InfosecArchitectureBot)

documentation

https://docs.rs/mauth-client/

README

mauth-client

mauth-client

This crate allows users of the Reqwest crate for making HTTP requests to sign those requests with the MAuth protocol, and verify the responses. Usage example:

Note: This crate and Rust support within Medidata is considered experimental. Do not release any code to Production or deploy in a Client-accessible environment without getting approval for the full stack used through the Architecture and Security groups.

use mauth_client::MAuthInfo;
use reqwest::Client;
let mauth_info = MAuthInfo::from_default_file().unwrap();
let client = Client::new();
let mut req = client.get("https://www.example.com/").build().unwrap();
mauth_info.sign_request(&mut req);
match client.execute(req).await {
    Err(err) => println!("Got error {}", err),
    Ok(response) => println!("Got validated response with body {}", response.text().await.unwrap()),
}

The above code will read your mauth configuration from a file in ~/.mauth_config.yml which format is:

common: &common
  mauth_baseurl: https://<URL of MAUTH SERVER>
  mauth_api_version: v1
  app_uuid: <YOUR APP UUID HERE>
  private_key_file: <PATH TO MAUTH KEY>

The optional axum-service feature provides for a Tower Layer and Service that will authenticate incoming requests via MAuth V2 or V1 and provide to the lower layers a validated app_uuid from the request via the ValidatedRequestDetails struct.

License: MIT

Commit count: 97

cargo fmt