Expand description

http_auth_basic

HTTP Basic Authentication Scheme (RFC 7617 base64-encoded credentials) for Rust applications

Example

Decoding a basic authorization value and creating a Credentials struct from it

use http_auth_basic::Credentials;

let auth_header_value = String::from("Basic dXNlcm5hbWU6cGFzc3dvcmQ=");
let credentials = Credentials::from_header(auth_header_value).unwrap();

assert_eq!(credentials.user_id, String::from("username"));
assert_eq!(credentials.password, String::from("password"));

Encoding Credentials into a basic authorization header value.

use http_auth_basic::Credentials;

let credentials = Credentials::new("username", "password");
let credentials = credentials.as_http_header();

assert_eq!(String::from("Basic dXNlcm5hbWU6cGFzc3dvcmQ="), credentials);

Structs

A struct to represent the user_id and password fields from an Authorization Basic header value

Enums

Authorization Header Error