Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-1815] Fix server auth when assets feature is enabled #2584

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub struct AppState {
auth: HashMap<String, SecStr>,
}

#[allow(unused)]
async fn basic_auth<B>(
State(state): State<AppState>,
request: Request<B>,
Expand Down Expand Up @@ -144,7 +143,6 @@ async fn main() {
}
}

#[cfg(not(feature = "assets"))]
let state = AppState { auth };

let (node, router) = match Node::new(
Expand Down Expand Up @@ -242,9 +240,15 @@ async fn main() {
);

#[cfg(not(feature = "assets"))]
let app = app.route("/", get(|| async { "Spacedrive Server!" }));

let app = app
.route("/", get(|| async { "Spacedrive Server!" }))
.fallback(|| async { "404 Not Found: We're past the event horizon..." })
.fallback(|| async {
(
http::StatusCode::NOT_FOUND,
"404 Not Found: We're past the event horizon...",
)
})
.layer(axum::middleware::from_fn_with_state(state, basic_auth));

let mut addr = "[::]:8080".parse::<SocketAddr>().unwrap(); // This listens on IPv6 and IPv4
Expand Down
Loading