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
Some checks failed
Build MIPS Binary / build (push) Has been cancelled
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -360,6 +360,7 @@ dependencies = [
|
|||||||
"shared",
|
"shared",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
@@ -907,6 +908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587"
|
checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -38,3 +38,4 @@ bcrypt = "0.17.0"
|
|||||||
axum-extra = { version = "0.9", features = ["cookie"] }
|
axum-extra = { version = "0.9", features = ["cookie"] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
anyhow = "1.0.101"
|
anyhow = "1.0.101"
|
||||||
|
time = { version = "0.3.47", features = ["serde", "formatting", "parsing"] }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub struct LoginRequest {
|
|||||||
password: String,
|
password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, ToSchema)]
|
||||||
pub struct UserResponse {
|
pub struct UserResponse {
|
||||||
username: String,
|
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(
|
pub async fn logout_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
jar: CookieJar,
|
jar: CookieJar,
|
||||||
@@ -93,6 +100,14 @@ pub async fn logout_handler(
|
|||||||
(StatusCode::OK, jar.add(cookie), "Logged out").into_response()
|
(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(
|
pub async fn check_auth_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
jar: CookieJar,
|
jar: CookieJar,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub struct SetupRequest {
|
|||||||
password: String,
|
password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, ToSchema)]
|
||||||
pub struct SetupStatusResponse {
|
pub struct SetupStatusResponse {
|
||||||
completed: bool,
|
completed: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ use axum::{
|
|||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
Router,
|
Router,
|
||||||
middleware::{self, Next},
|
middleware::{self, Next},
|
||||||
extract::Request,
|
|
||||||
response::Response,
|
response::Response,
|
||||||
http::StatusCode,
|
http::{StatusCode, Request},
|
||||||
body::Body,
|
body::Body,
|
||||||
};
|
};
|
||||||
use axum_extra::extract::cookie::CookieJar;
|
use axum_extra::extract::cookie::CookieJar;
|
||||||
@@ -47,7 +46,7 @@ pub struct AppState {
|
|||||||
async fn auth_middleware(
|
async fn auth_middleware(
|
||||||
state: axum::extract::State<AppState>,
|
state: axum::extract::State<AppState>,
|
||||||
jar: CookieJar,
|
jar: CookieJar,
|
||||||
request: Request<Body>,
|
request: Request,
|
||||||
next: Next,
|
next: Next,
|
||||||
) -> Result<Response, StatusCode> {
|
) -> Result<Response, StatusCode> {
|
||||||
// Skip auth for public paths
|
// Skip auth for public paths
|
||||||
@@ -72,7 +71,6 @@ async fn auth_middleware(
|
|||||||
|
|
||||||
Err(StatusCode::UNAUTHORIZED)
|
Err(StatusCode::UNAUTHORIZED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
|||||||
Reference in New Issue
Block a user