Description
The "Basic" Hypertext Transfer Protocol (HTTP) authentication scheme, transmits credentials as user-id/password pairs, encoded using Base64.
The server will gather the credentials from the base64 encoded header value, and will validate them to authenticate the user in question.
This crate covers the credentials encoding and decoding. The Credentials struct provides two fields
user_id and password, these are filled with they raw values.
Installation
To install add the crate as follows to your dependencies list in your Cargo.toml.
[]
= "0.1.1"
If you want to use a specific version, you must add the crate to your Cargo.toml as follows:
[]
= { = "https://github.com/EstebanBorai/http-auth-basic.git", = "v0.1.0" }
Usage
Decoding a basic authorization value and creating a Credentials struct
from it
use Credentials;
let auth_header_value = Stringfrom;
let credentials = from_header.unwrap;
assert_eq!;
assert_eq!;
Encoding Credentials into a basic authorization header value.
use Credentials;
let credentials = new;
let credentials = credentials.as_http_header;
assert_eq!;
Release
Contributing
Every contribution to this project is welcome! Feel free to open a pull request or an issue.
References
License
Licensed under the GNU General Public License.