fix: basic auth sometimes does not work (#194)

This commit is contained in:
sigoden
2023-03-12 12:58:36 +08:00
committed by GitHub
parent 8d7a9053e2
commit c92e45f2da
2 changed files with 8 additions and 4 deletions

View File

@@ -211,7 +211,7 @@ impl AuthMethod {
pub fn get_user(&self, authorization: &HeaderValue) -> Option<String> {
match self {
AuthMethod::Basic => {
let value: Vec<u8> = general_purpose::STANDARD_NO_PAD
let value: Vec<u8> = general_purpose::STANDARD
.decode(strip_prefix(authorization.as_bytes(), b"Basic ")?)
.ok()?;
let parts: Vec<&str> = std::str::from_utf8(&value).ok()?.split(':').collect();
@@ -236,7 +236,7 @@ impl AuthMethod {
) -> Option<()> {
match self {
AuthMethod::Basic => {
let basic_value: Vec<u8> = general_purpose::STANDARD_NO_PAD
let basic_value: Vec<u8> = general_purpose::STANDARD
.decode(strip_prefix(authorization.as_bytes(), b"Basic ")?)
.ok()?;
let parts: Vec<&str> = std::str::from_utf8(&basic_value).ok()?.split(':').collect();