Initial implementation: relay server + common protocol + client stub

This commit is contained in:
Helios 2026-03-02 18:03:46 +01:00
commit 7285a33cff
No known key found for this signature in database
GPG key ID: C8259547CD8309B5
17 changed files with 926 additions and 0 deletions

26
crates/server/src/auth.rs Normal file
View file

@ -0,0 +1,26 @@
use axum::{
extract::{Request, State},
http::StatusCode,
middleware::Next,
response::Response,
};
use crate::AppState;
/// Axum middleware that checks the `X-Api-Key` header.
pub async fn require_api_key(
State(state): State<AppState>,
req: Request,
next: Next,
) -> Result<Response, StatusCode> {
let key = req
.headers()
.get("X-Api-Key")
.and_then(|v| v.to_str().ok())
.unwrap_or("");
if key != state.api_key {
return Err(StatusCode::UNAUTHORIZED);
}
Ok(next.run(req).await)
}