feat: complete Rust backend UI compatibility

This commit is contained in:
boos
2026-05-18 16:52:54 +08:00
parent f2434e725d
commit f986fe0377
41 changed files with 3585 additions and 811 deletions
+6 -3
View File
@@ -29,6 +29,7 @@ use tracing::info;
// ── Auth types ────────────────────────────────────────────────────────
#[allow(dead_code)]
#[derive(Clone)]
pub struct ProxyAuth {
pub token: String,
@@ -36,6 +37,7 @@ pub struct ProxyAuth {
pub source: DownstreamSource,
}
#[allow(dead_code)]
#[derive(Clone, PartialEq)]
pub enum DownstreamSource {
Managed { key_id: i64 },
@@ -279,12 +281,12 @@ async fn check_auth(state: &AppState, headers: &HeaderMap) -> Result<(), AppErro
.get("Authorization")
.and_then(|v| v.to_str().ok())
.and_then(|v| v.strip_prefix("Bearer "))
.and_then(|v| v.trim().split_whitespace().next())
.and_then(|v| v.split_whitespace().next())
.ok_or_else(|| AppError::Unauthorized("Missing Authorization header".into()))?;
let result = authorize_downstream_token(auth, &state.db)
let result = authorize_downstream_token(auth, &state.db, Some(&state.config.auth.proxy_token))
.await
.map_err(|e| AppError::Unauthorized(e))?;
.map_err(AppError::Unauthorized)?;
match result {
DownstreamAuthResult::Managed { key, .. } => {
@@ -646,6 +648,7 @@ mod tests {
max_retries: 3,
proxy_log_retention_days: 7,
},
comfyui: Default::default(),
},
pool,
)