Skip to main content

Module basic

Module basic 

Source
Expand description

HTTP Basic authentication scheme: credentials are sent as a base64-encoded username:password pair in the Authorization request header (RFC 7617 §2).

§Example

use io_http::rfc7617::basic::BasicCredentials;
use secrecy::ExposeSecret;

let creds = BasicCredentials::new("Aladdin", "open sesame");
assert_eq!(creds.to_authorization(), "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");

let parsed = BasicCredentials::from_authorization("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==").unwrap();
assert_eq!(parsed.username, "Aladdin");
assert_eq!(parsed.password.expose_secret(), "open sesame");

Structs§

BasicCredentials
HTTP Basic credential pair; password is redacted in fmt::Debug and zeroed on drop.

Enums§

BasicError
Failure causes when parsing a Basic authorization value.