The "Basic" Hypertext Transfer Protocol (HTTP) authentication scheme, transmits credentials as user-id/password pairs, encoded using Base64.
To install add the crate as follows to your dependencies list in your Cargo.toml
.
toml
[dependencies]
http-auth-basic = "0.1.0"
If you want to use a specific version, you must add the crate to your Cargo.toml
as follows:
toml
[dependencies]
http-auth-basic = { git = "https://github.com/EstebanBorai/http-auth-basic.git", tag = "v0.1.0" }
Decoding a basic authorization value and creating a Credentials
struct
from it
```rust use httpauthbasic::Credentials;
let authheadervalue = String::from("Basic dXNlcm5hbWU6cGFzc3dvcmQ="); let credentials = Credentials::fromheader(authheader_value).unwrap();
asserteq!(credentials.userid, String::from("username")); assert_eq!(credentials.password, String::from("password")); ```
Encoding Credentials
into a basic authorization header value.
```rust use httpauthbasic::Credentials;
let credentials = Credentials::new("username", "password"); let credentials = credentials.ashttpheader();
assert_eq!(String::from("Basic dXNlcm5hbWU6cGFzc3dvcmQ="), credentials); ```
bash
git tag -a v0.1.0 -m "Release Message"
git push origin main --follow-tags
Every contribution to this project is welcome! Feel free to open a pull request or an issue.
Licensed under the GNU General Public License.