fix: resolve overlapping route and deprecated base64 decode usage

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-13 13:05:14 -03:00
parent 50150ce23d
commit 20a227fc9e
4 changed files with 3 additions and 7 deletions

View File

@@ -130,7 +130,7 @@ pub async fn handle_list_items(
) )
)] )]
pub async fn handle_post_item( pub async fn handle_post_item(
State(state): State<AppState>, State(_state): State<AppState>,
) -> Result<Json<ApiResponse<ItemInfo>>, StatusCode> { ) -> Result<Json<ApiResponse<ItemInfo>>, StatusCode> {
// This is a simplified implementation // This is a simplified implementation

View File

@@ -16,7 +16,6 @@ use utoipa_swagger_ui::SwaggerUi;
status::handle_status, status::handle_status,
item::handle_list_items, item::handle_list_items,
item::handle_post_item, item::handle_post_item,
item::handle_delete_item,
item::handle_get_item_latest, item::handle_get_item_latest,
item::handle_get_item_latest_meta, item::handle_get_item_latest_meta,
item::handle_get_item_latest_content, item::handle_get_item_latest_content,
@@ -55,7 +54,4 @@ pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> { pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
router router
.merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi())) .merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi()))
.route("/openapi.json", axum::routing::get(|| async {
axum::Json(ApiDoc::openapi())
}))
} }

View File

@@ -3,7 +3,6 @@ use axum::{
http::StatusCode, http::StatusCode,
response::Json, response::Json,
}; };
use log::warn;
use crate::modes::server::common::{AppState, ApiResponse}; use crate::modes::server::common::{AppState, ApiResponse};
use crate::common::status::{generate_status_info, StatusInfo}; use crate::common::status::{generate_status_info, StatusInfo};

View File

@@ -5,6 +5,7 @@ use axum::{
middleware::Next, middleware::Next,
response::Response, response::Response,
}; };
use base64::Engine;
use log::{info, warn}; use log::{info, warn};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
@@ -80,7 +81,7 @@ fn check_basic_auth(auth_str: &str, expected_password: &str) -> bool {
} }
let encoded = &auth_str[6..]; let encoded = &auth_str[6..];
if let Ok(decoded_bytes) = base64::decode(encoded) { if let Ok(decoded_bytes) = base64::engine::general_purpose::STANDARD.decode(encoded) {
if let Ok(decoded_str) = String::from_utf8(decoded_bytes) { if let Ok(decoded_str) = String::from_utf8(decoded_bytes) {
let expected_credentials = format!("keep:{}", expected_password); let expected_credentials = format!("keep:{}", expected_password);
return decoded_str == expected_credentials; return decoded_str == expected_credentials;