Fix compilation errors: Resolve utoipa derive issues, add time dependency, and correct Axum middleware signature
Some checks failed
Build MIPS Binary / build (push) Has been cancelled

This commit is contained in:
spinline
2026-02-07 15:08:53 +03:00
parent bb3ec14a75
commit 472bac85f3
5 changed files with 22 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -360,6 +360,7 @@ dependencies = [
"shared",
"sqlx",
"thiserror 2.0.18",
"time",
"tokio",
"tokio-stream",
"tokio-util",
@@ -907,6 +908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587"
dependencies = [
"powerfmt",
"serde_core",
]
[[package]]

View File

@@ -38,3 +38,4 @@ bcrypt = "0.17.0"
axum-extra = { version = "0.9", features = ["cookie"] }
rand = "0.8"
anyhow = "1.0.101"
time = { version = "0.3.47", features = ["serde", "formatting", "parsing"] }

View File

@@ -15,7 +15,7 @@ pub struct LoginRequest {
password: String,
}
#[derive(Serialize)]
#[derive(Serialize, ToSchema)]
pub struct UserResponse {
username: String,
}
@@ -76,6 +76,13 @@ pub async fn login_handler(
}
}
#[utoipa::path(
post,
path = "/api/auth/logout",
responses(
(status = 200, description = "Logged out")
)
)]
pub async fn logout_handler(
State(state): State<AppState>,
jar: CookieJar,
@@ -93,6 +100,14 @@ pub async fn logout_handler(
(StatusCode::OK, jar.add(cookie), "Logged out").into_response()
}
#[utoipa::path(
get,
path = "/api/auth/check",
responses(
(status = 200, description = "Authenticated"),
(status = 401, description = "Not authenticated")
)
)]
pub async fn check_auth_handler(
State(state): State<AppState>,
jar: CookieJar,

View File

@@ -13,7 +13,7 @@ pub struct SetupRequest {
password: String,
}
#[derive(Serialize)]
#[derive(Serialize, ToSchema)]
pub struct SetupStatusResponse {
completed: bool,
}

View File

@@ -12,9 +12,8 @@ use axum::{
routing::{get, post},
Router,
middleware::{self, Next},
extract::Request,
response::Response,
http::StatusCode,
http::{StatusCode, Request},
body::Body,
};
use axum_extra::extract::cookie::CookieJar;
@@ -47,7 +46,7 @@ pub struct AppState {
async fn auth_middleware(
state: axum::extract::State<AppState>,
jar: CookieJar,
request: Request<Body>,
request: Request,
next: Next,
) -> Result<Response, StatusCode> {
// Skip auth for public paths
@@ -72,7 +71,6 @@ async fn auth_middleware(
Err(StatusCode::UNAUTHORIZED)
}
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {