mauth-core

Crates.iomauth-core
lib.rsmauth-core
version0.5.0
sourcesrc
created_at2024-05-22 23:43:40.112402
updated_at2024-06-07 18:06:54.196973
descriptionGenerate and verify Medidata MAuth protocol signatures
homepagehttps://github.com/mdsol/mauth-core
repositoryhttps://github.com/mdsol/mauth-core
max_upload_size
id1248890
size41,066
(InfosecArchitectureBot)

documentation

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

README

MAuth Core

A library to generate and verify MAuth signatures

Usage

Add the following to your Cargo.toml:

[dependencies]
mauth-core = "0.5"

Here is an example of generating and verifying a signature:

use mauth_core::signer::Signer;
use mauth_core::verifier::Verifier;
use mauth_core::error::Error;

let mauth_version = 2;
let private_key_data = std::fs::read_to_string("tests/mauth-protocol-test-suite/signing-params/rsa-key").unwrap();
let public_key_data = std::fs::read_to_string("tests/mauth-protocol-test-suite/signing-params/rsa-key-pub").unwrap();
let app_uuid = "101c139a-236c-11ef-b5e3-125eb8485a60".to_string();
let verb = "GET";
let path = "/item";
let query = "page=2";
let body = b"";
let timestamp = "2024-01-28T19:11:35.000";

let signer = Signer::new(app_uuid.clone(), private_key_data);
assert!(signer.is_ok());
let signature = signer.unwrap().sign_string(mauth_version, verb, path, query, body, timestamp);
assert!(signature.is_ok());

let verifier = Verifier::new(app_uuid.clone(), public_key_data);
assert!(verifier.is_ok());
let result = verifier.unwrap().verify_signature(mauth_version, verb, path, query, body, timestamp, signature.unwrap());
assert!(result.is_ok());

You can find an example of binding MAuth Core to Ruby here.

Contributing

See CONTRIBUTING.

Commit count: 44

cargo fmt