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
21 lines
736 B
Rust
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"})),
|
|
}
|
|
}
|