aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2021-10-13 02:09:04 +0000
committerAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2021-10-13 02:09:04 +0000
commit251f20858d8e48ebc045cfdd997c1e40dffdbf11 (patch)
tree285cc75e3b5a9188d1c782ac21df572d48a0c5fe /src/main.rs
parentMerge pull request #613 from svenstaro/dependabot/cargo/assert_fs-1.0.6 (diff)
downloadminiserve-251f20858d8e48ebc045cfdd997c1e40dffdbf11.tar.gz
miniserve-251f20858d8e48ebc045cfdd997c1e40dffdbf11.zip
revert unnecessary changes
Diffstat (limited to '')
-rw-r--r--src/main.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 133f320..cb11145 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,6 +7,7 @@ use std::time::Duration;
use actix_web::web;
use actix_web::{http::header::ContentType, Responder};
use actix_web::{middleware, App, HttpRequest, HttpResponse};
+use actix_web_httpauth::middleware::HttpAuthentication;
use anyhow::{bail, Result};
use clap::{crate_version, Clap, IntoApp};
use clap_generate::generators::{Bash, Elvish, Fish, PowerShell, Zsh};
@@ -211,11 +212,10 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
.route(&format!("/{}", inside_config.css_route), web::get().to(css))
.service(
web::scope(inside_config.random_route.as_deref().unwrap_or(""))
- // we should use `actix_web_httpauth::middleware::HttpAuthentication`
- // but it is unfortuantrly broken
- // see: https://github.com/actix/actix-extras/issues/127
- // TODO replace this when fixed upstream
- .wrap_fn(auth::auth_middleware)
+ .wrap(middleware::Condition::new(
+ !inside_config.auth.is_empty(),
+ HttpAuthentication::basic(auth::handle_auth),
+ ))
.configure(|c| configure_app(c, &inside_config)),
)
.default_service(web::get().to(error_404))