diff options
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/auth.rs | 10 |
3 files changed, 9 insertions, 7 deletions
@@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "actix-web-httpauth" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c25a48b4684f90520183cd1a688e5f4f7e9905835fa75d02c0fe4f60fcdbe6" +checksum = "a6dc1123f18b3548b9fe90c15e9bd77819701b047c6b62c152230aa39243d40d" dependencies = [ "actix-service", "actix-utils", @@ -20,7 +20,7 @@ panic = 'abort' actix-web = "4" actix-files = "0.6" actix-multipart = "0.4" -actix-web-httpauth = "0.6" +actix-web-httpauth = "0.7" maud = "0.23" yansi = "0.5" simplelog = "0.12" diff --git a/src/auth.rs b/src/auth.rs index 1b11557..b2c01e3 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -77,16 +77,18 @@ pub struct CurrentUser { pub async fn handle_auth( req: ServiceRequest, cred: BasicAuth, -) -> actix_web::Result<ServiceRequest> { +) -> actix_web::Result<ServiceRequest, (actix_web::Error, ServiceRequest)> { let required_auth = &req.app_data::<crate::MiniserveConfig>().unwrap().auth; req.extensions_mut().insert(CurrentUser { name: cred.user_id().to_string(), }); - match_auth(&cred.into(), required_auth) - .then(|| req) - .ok_or_else(|| ContextualError::InvalidHttpCredentials.into()) + if match_auth(&cred.into(), required_auth) { + Ok(req) + } else { + Err((ContextualError::InvalidHttpCredentials.into(), req)) + } } #[rustfmt::skip] |