guard/crates/rampart-manager/src/api/auth.rs
loki5512344 cf9608ce5d
Initial commit: Rampart v0.2.0
Multi-layer DDoS protection for Minecraft servers.

- rampart-core: Edge node with XDP/eBPF + Rust L7 filtering
- rampart-manager: REST API with JWT auth, Redis sync
- rampart-cli: CLI tool for operators
- velocity-plugin: Domain check, HMAC verify, server registry, load balancer
- paper-plugin: Auto-registration, heartbeat, HMAC verify
- dashboard: React + Vite web UI for management
2026-07-20 20:53:32 +02:00

21 lines
736 B
Rust

use crate::AppState;
use axum::{Json, extract::State};
use serde::Deserialize;
use std::sync::Arc;
#[derive(Deserialize)]
pub struct LoginRequest {
pub password: String,
}
pub async fn login(State(state): State<Arc<AppState>>, Json(req): Json<LoginRequest>) -> Json<serde_json::Value> {
let api_password = std::env::var("API_PASSWORD").unwrap_or_else(|_| "changeme".to_string());
if req.password != api_password {
return Json(serde_json::json!({"error": "invalid password"}));
}
match crate::auth::create_token(&state.jwt_secret, state.jwt_expiration) {
Ok(token) => Json(serde_json::json!({"token": token})),
Err(_) => Json(serde_json::json!({"error": "token creation failed"})),
}
}