From 546c9cd69fcad11a6445eb616870132f0b1d7186 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Thu, 23 Apr 2026 02:58:01 +0300 Subject: [PATCH] feat: Add authentication configuration with JWT secret and reorganize environment variables with categorized sections - Add AuthConfig struct with JWTSecret field to config package - Add Auth field to Config struct with JSON tag for authentication settings - Add JWT_SECRET to Auth config with default value "change-me-in-production" - Replace MONGODB_URI with DATABASE_URL using PostgreSQL connection string in .env.example - Add categorized sections in .env.example: Database/Server/Authentication/ --- apps/api-server/.env.example | 13 +++++++++++-- apps/api-server/internal/config/config.go | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/api-server/.env.example b/apps/api-server/.env.example index c6b6ffc..f2a6dbc 100644 --- a/apps/api-server/.env.example +++ b/apps/api-server/.env.example @@ -1,6 +1,15 @@ -MONGODB_URI=mongodb://localhost:27017/free5gc +# Database Configuration +DATABASE_URL=postgres://telecom:password@localhost:5432/telecom_platform?sslmode=disable REDIS_URI=redis://localhost:6379 + +# Server Configuration API_PORT=8000 GIN_MODE=debug -JWT_SECRET=change-me-in-production LOG_LEVEL=info + +# Authentication +JWT_SECRET=change-me-in-production + +# External Services +PROMETHEUS_URL=http://localhost:9090 +KUBERNETES_NAMESPACE=telecom-platform diff --git a/apps/api-server/internal/config/config.go b/apps/api-server/internal/config/config.go index 268fae5..2235d1b 100644 --- a/apps/api-server/internal/config/config.go +++ b/apps/api-server/internal/config/config.go @@ -13,6 +13,7 @@ type Config struct { Payment PaymentConfig `json:"payment"` ChargingEngine ChargingEngineConfig `json:"charging_engine"` InfluxDB InfluxDBConfig `json:"influxdb"` + Auth AuthConfig `json:"auth"` } type ChargingEngineConfig struct { @@ -69,6 +70,10 @@ type ES2Config struct { FunctionalityRequesterID string `json:"functionality_requester_id"` } +type AuthConfig struct { + JWTSecret string `json:"jwt_secret"` +} + func LoadConfig() *Config { return &Config{ Server: ServerConfig{ @@ -117,5 +122,8 @@ func LoadConfig() *Config { Org: "telecom", Bucket: "telecom", }, + Auth: AuthConfig{ + JWTSecret: "change-me-in-production", + }, } }