mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-07 07:53:33 +00:00
parent
10df655fba
commit
d9b31a90b3
|
@ -29,7 +29,9 @@ async fn basic_auth<B>(
|
||||||
request: Request<B>,
|
request: Request<B>,
|
||||||
next: Next<B>,
|
next: Next<B>,
|
||||||
) -> Response {
|
) -> Response {
|
||||||
|
let request = if state.auth.len() != 0 {
|
||||||
let (mut parts, body) = request.into_parts();
|
let (mut parts, body) = request.into_parts();
|
||||||
|
|
||||||
let Ok(TypedHeader(Authorization(hdr))) =
|
let Ok(TypedHeader(Authorization(hdr))) =
|
||||||
TypedHeader::<Authorization<Basic>>::from_request_parts(&mut parts, &()).await
|
TypedHeader::<Authorization<Basic>>::from_request_parts(&mut parts, &()).await
|
||||||
else {
|
else {
|
||||||
|
@ -41,7 +43,6 @@ async fn basic_auth<B>(
|
||||||
};
|
};
|
||||||
let request = Request::from_parts(parts, body);
|
let request = Request::from_parts(parts, body);
|
||||||
|
|
||||||
if state.auth.len() != 0 {
|
|
||||||
if state
|
if state
|
||||||
.auth
|
.auth
|
||||||
.get(hdr.username())
|
.get(hdr.username())
|
||||||
|
@ -54,7 +55,11 @@ async fn basic_auth<B>(
|
||||||
.body("Unauthorized".into_response().into_body())
|
.body("Unauthorized".into_response().into_body())
|
||||||
.expect("hardcoded response will be valid");
|
.expect("hardcoded response will be valid");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
request
|
||||||
|
} else {
|
||||||
|
request
|
||||||
|
};
|
||||||
|
|
||||||
next.run(request).await
|
next.run(request).await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue