feat: Add authentication middleware to charging-engine with public and protected route separation

- Add auth module import to main.rs
- Add AuthConfig initialization from environment in main function
- Add auth_config field to AppState struct
- Add auth_middleware layer to protected routes
- Move health check, credit check, deduct, balance, and usage recording to public routes (no auth required for packet-gateway integration)
- Move add credit, subscriber management, rating plans, monitoring, and engine
This commit is contained in:
nutcas3
2026-04-25 03:38:14 +03:00
parent a41431c17a
commit 3cef1fbf03
3 changed files with 14 additions and 3 deletions
+4
View File
@@ -1,3 +1,4 @@
mod auth;
mod charging;
mod monitoring;
mod errors;
@@ -11,6 +12,7 @@ use tracing::info;
use routes::create_router;
use charging::{ChargingEngine, RatingPlansRepo};
use auth::AuthConfig;
#[tokio::main]
async fn main() -> Result<()> {
@@ -44,8 +46,10 @@ async fn main() -> Result<()> {
info!("Connected to Redis successfully");
// Create application state
let auth_config = AuthConfig::from_env();
let state = crate::models::AppState {
charging_engine,
auth_config,
};
// Create router