use crate::security::SecurityManager;
use crate::server::http_server::AppState;
use actix_web::{web, HttpResponse, Result as ActixResult};
use serde_json::json;
use std::sync::Arc;
async fn get_security_manager(data: &web::Data<AppState>) -> Arc<SecurityManager> {
let node_guard = data.node.read().await;
node_guard.get_security_manager().clone()
}
#[utoipa::path(
get,
path = "/api/security/system-key",
tag = "security",
responses((status = 200, description = "System key"), (status = 404, description = "Not found"))
)]
pub async fn get_system_public_key(data: web::Data<AppState>) -> ActixResult<HttpResponse> {
let security_manager = get_security_manager(&data).await;
match security_manager.get_system_public_key() {
Ok(Some(key_info)) => Ok(HttpResponse::Ok().json(json!({
"success": true,
"key": key_info
}))),
Ok(None) => Ok(HttpResponse::NotFound().json(json!({
"success": false,
"error": "System key not found"
}))),
Err(e) => Ok(HttpResponse::InternalServerError().json(json!({
"success": false,
"error": e.to_string()
}))),
}
}
#[cfg(test)]
mod tests {
#[test]
fn minimal() {
}
}