Commit Graph
463 Commits
Author SHA1 Message Date
nutcas3 b443152ecc feat: Add Traefik configuration with security middlewares, rate limiting, and dynamic routing
- Add traefik.yml with HTTP to HTTPS redirection and secure-headers middleware
- Add dashboard on port 80 with insecure mode enabled
- Add websecure entrypoint on port 443 with security headers
- Add Docker and file providers with dynamic configuration watching
- Add Prometheus metrics with entrypoint and service labels
- Add middlewares.yml with secure-headers including CSP, X-Frame-Options, and Permissions
2026-05-01 09:07:13 +03:00
nutcas3 19eb36613b docs: Add Traefik API Gateway documentation and update README with unified endpoint architecture
- Add API Gateway Integration section describing Traefik-based centralized routing
- Add API Gateway Layer to architecture overview with SSL termination and monitoring
- Add Gateway & Security features including unified HTTPS endpoint and JWT validation
- Update Technology Stack to Rust 1.95 from 1.94
- Add Quick Start with API Gateway section using start-gateway.sh script
- Add traefik/ directory
2026-05-01 09:07:01 +03:00
nutcas3 1cbe66a0c0 refactor: Add context parameter to MessageQueue Publish method with timeout wrapping
- Add context.Context parameter to Publish method signature
- Replace context.Background() with provided context wrapped in timeout
- Rename timeout context variable from ctx to timeoutCtx for clarity
2026-05-01 09:06:43 +03:00
nutcas3 783d5c147b feat: Add XSS protection and HATEOAS links to subscriber and auth handlers with cursor pagination
- Add bluemonday import to auth.go and subscriber.go
- Add UGCPolicy sanitization for username, email, firstName, lastName, and role in Register
- Add conditional XSS sanitization for firstName, lastName, email, and MSISDN in CreateSubscriber and UpdateSubscriber
- Replace Page and PageSize with Cursor and Limit in ListSubscribers query parameters
- Add HATEOAS links to CreateSubscriber, GetSubscriber
2026-05-01 09:06:32 +03:00
nutcas3 36748d534e refactor: Replace offset pagination with cursor-based pagination for subscriber listing
- Replace Page and PageSize with Cursor and Limit in ListSubscribersRequest
- Replace Total, Page, and PageSize with NextCursor and HasMore in ListSubscribersResponse
- Add default limit of 20 with max cap of 100 in ListSubscribers
- Replace ListSubscribers call with ListSubscribersCursor in subscriber_crud.go
- Remove unused database import from subscriber_crud.go
- Replace context.Background() with context.Without
2026-05-01 09:06:13 +03:00
nutcas3 444d767ceb feat: Add CSRF protection middleware to carrier-connector with secret validation
- Add gin-csrf middleware import to main.go
- Add CSRF_SECRET environment variable support with default fallback warning
- Add CSRF middleware to Gin router with configurable secret
- Add default CSRF secret with production warning for missing environment variable
2026-05-01 09:05:38 +03:00
nutcas3 49dc77d241 feat: Add CSP, Referrer-Policy, and Permissions-Policy headers to SecurityHeadersMiddleware
- Add Content-Security-Policy header with self-only defaults and unsafe-inline styles
- Add Referrer-Policy header with strict-origin-when-cross-origin
- Add Permissions-Policy header blocking geolocation, microphone, and camera access
2026-05-01 09:05:02 +03:00
nutcas3 5b6cee5618 feat: Add cursor-based pagination for subscribers and parameterize test password
- Add ListSubscribersCursor method to Database with ID-based cursor pagination
- Add cursor, hasMore, and nextCursor support for efficient pagination
- Add status, organizationID, and search filters to cursor-based query
- Add limit+1 fetch strategy to detect additional results
- Add fmt import to database/crud.go
- Add TEST_PASSWORD environment variable support in integration tests with default fallback
- Replace hard
2026-05-01 09:04:41 +03:00
nutcas3 4b04048c9b feat: Add SSRF protection to charging engine client with URL validation and domain whitelisting
- Add validateURL method to ChargingEngineClient with private IP blocking and domain whitelisting
- Add SSRF validation to CheckCredit, DeductCredit, AddCredit, GetBalance, and HealthCheck endpoints
- Add errors, net, url, and slices imports to charging_client.go
- Update HealthCheck endpoint from /health to /v1/health for consistency
- Add allowed domains list including localhost, 127.0.0.1, charging
2026-05-01 09:03:25 +03:00
nutcas3 b2376e2133 feat: Add HATEOAS link support for subscriber resources with navigation and action links
- Add Link struct with href, rel, and optional type fields
- Add Links map type for HATEOAS link collections
- Add SubscriberWithLinks and SubscriberListWithLinks wrapper types
- Add NewSubscriberLinks function generating self, update, delete, billing, and sessions links
- Add NewSubscriberListLinks function with self, create, and conditional next pagination links
2026-05-01 09:02:12 +03:00
nutcas3 972be70cc2 feat: Add API Gateway startup script with health checks and service validation
- Add start-gateway.sh script for Traefik-based API Gateway deployment
- Add JWT_SECRET environment variable validation with development fallback warning
- Create traefik/dynamic directory for dynamic configuration
- Add docker-compose orchestration with build and detached mode
- Add health check endpoints for Traefik (/ping), API Server (/api/v1/health), and Charging Engine (/v1/health)
- Add service URL documentation
2026-05-01 09:01:20 +03:00
nutcas3 4e4b13f3e8 refactor: Simplify validation parsing using let-chains in sync.rs and wrap unsafe env::set_var in tests
- Replace nested if-let statements with let-chain pattern for VmRSS memory parsing in /proc/self/status
- Replace nested if-let statements with let-chain pattern for Redis used_memory parsing
- Wrap std::env::set_var calls in unsafe blocks in validation_tests.rs for MAX_BYTES_LIMIT and MAX_AMOUNT_LIMIT
2026-05-01 00:43:54 +03:00
nutcas3 11065b827b refactor: Simplify Redis RPS extraction using let-chains in monitoring_impl.rs
- Replace nested if-let statements with let-chain pattern for Redis RPS parsing
- Update module reference from monitoring to monitoring_impl in monitoring.rs
2026-05-01 00:43:41 +03:00
nutcas3 220b7e0380 refactor: Rename monitoring.rs to monitoring_impl.rs in charging-engine 2026-05-01 00:43:22 +03:00
nutcas3 dd346a7484 refactor: Update Rust version to 1.95, add SSRF protection to ES2 client, and fix CLI API endpoint paths
- Change rust-version from "1.94" to "1.95" in workspace Cargo.toml
- Add validateURL method to ES2Client with private IP blocking and domain whitelisting
- Add SSRF validation to DownloadProfile and GetProfileStatus endpoints
- Add slices, errors, net, and url imports to es2/client.go
- Update CLI charging API endpoints from /v1 to /api/v1 prefix
- Fix DeductCredit response handling to use nil
2026-05-01 00:41:57 +03:00
nutcas3 b1f18e1a4e feat: Add comprehensive Swagger API documentation for subscriber management endpoints
- Add GET /api/v1/subscribers endpoint with pagination and filtering parameters
- Add POST /api/v1/subscribers endpoint for subscriber creation
- Add GET /api/v1/subscribers/{id} and GET /api/v1/subscribers/imsi/{imsi} endpoints
- Add PUT /api/v1/subscribers/{id} endpoint for subscriber updates
- Add POST /api/v1/subscribers/{id}/suspend and /api/v1/subscribers/{id}/terminate endpoints
- Add Swagger definitions
2026-04-30 22:59:46 +03:00
nutcas3 2e813c3d90 refactor: Add CSRF protection and session management dependencies to carrier-connector
- Add github.com/utrack/gin-csrf v0.0.0 for CSRF protection
- Add github.com/gin-contrib/sessions and related session management dependencies
- Add github.com/gorilla/context, gorilla/securecookie, and gorilla/sessions for session handling
- Add github.com/dchest/uniuri for unique identifier generation
- Add indirect dependencies for various session store implementations (redistore, memcache, mongostore)
2026-04-30 22:55:19 +03:00
nutcas3 cebed0a904 feat: Add CSRF protection middleware and Swagger annotations, remove GraphQL handler setup
- Add github.com/utrack/gin-csrf import for CSRF protection
- Remove internal/graphql import and resolver initialization
- Add Swagger API documentation annotations (@title, @version, @description, @host, @BasePath, @securityDefinitions)
- Add CSRF middleware with configurable secret from CSRF_SECRET environment variable
- Add warning log when using default CSRF secret
- Add return statement after database
2026-04-30 22:53:09 +03:00
nutcas3 51c1ad6573 feat: Add Swagger documentation endpoint and update API route prefix from /v1 to /api/v1
- Add swaggo/files and swaggo/gin-swagger imports for Swagger documentation
- Change API route group prefix from "/v1" to "/api/v1"
- Add GET /api/v1/swagger/*any endpoint for Swagger UI documentation
- Update RBAC path from "/v1/users" to "/api/v1/users" for consistency
2026-04-30 22:49:51 +03:00
nutcas3 eff0da097d feat: Add Traefik reverse proxy with TLS routing and rate limiting for all services
- Add traefik service with v3.0 image exposing ports 80, 443, and 8080 (dashboard)
- Mount traefik configuration directory and Docker socket for service discovery
- Change api-server, carrier-connector, and charging-engine from ports to expose
- Add Traefik labels to api-server for /api/v1 routes with rate limiting, secure headers, and compression
- Add separate router for api-server Swagger docs at /api/v1/swagger with relaxed rate limits
- Add Traefik labels to carrier-connector for /v1/es2 and /v1/carrier routes
2026-04-30 22:46:42 +03:00
nutcas3 afe4084ae2 refactor: Replace log.Printf with structured logging using logrus in api-server metrics collection
- Remove standard log import from server_metrics.go
- Add logrus import for structured logging
- Replace log.Printf with logrus.WithError for system metrics storage errors
- Replace log.Printf with logrus.WithError for subscriber count errors (total, active, suspended)
- Replace log.Printf with logrus.WithError for active sessions count errors
- Replace log.Printf with logrus.WithError for /proc/stat, /proc/meminfo, and /proc/net/dev read errors
2026-04-30 22:43:37 +03:00
nutcas3 1bb9b64322 refactor: Replace GraphQL dependencies with CSRF protection and HTML sanitization in api-server
- Remove github.com/99designs/gqlgen and github.com/vektah/gqlparser/v2 GraphQL dependencies
- Add github.com/utrack/gin-csrf v0.0.0 for CSRF protection
- Add github.com/microcosm-cc/bluemonday v1.0.27 for HTML sanitization
- Add github.com/gin-contrib/sessions and related session management dependencies
- Remove GraphQL-related indirect dependencies (agnivade/levenshtein, hashicorp/golang-lru/v2, so
2026-04-30 22:41:21 +03:00
nutcas3 f8504de4ef refactor: Remove generated GraphQL code and resolver files from api-server
- Delete generated.go containing GraphQL type definitions, resolvers, and schema
- Delete resolvers.go containing root Resolver struct and helper functions
- Remove GraphQL enum constants (SubscriberStatus, ProfileStatus, UsageType, etc.)
- Remove GraphQL input types (SubscriberFilter, CreateSubscriberInput, etc.)
- Remove GraphQL output types (PageInfo, SubscriberConnection, UsageStats, etc.)
- Remove resolver interfaces
2026-04-30 04:57:58 +03:00
nutcas3 9b64366e25 refactor: Fix Rust edition, remove duplicate lint rule, and improve error handling in charging-engine and packet-gateway
- Change Rust edition from "2026" to "2024" in workspace Cargo.toml
- Remove duplicate expect_used lint rule from workspace lints
- Prefix unused account variable with underscore in calculate_usage_cost
- Split CARGO_MANIFEST_DIR assignment into separate variable in run_migrations
- Clone plan_id before moving plan in add_rating_plan handler
- Replace expect() with unwrap() in governor
2026-04-30 03:17:46 +03:00
nutcas3 cd392894df refactor: Replace manual map copy with maps.Copy in carrier-connector message queue
- Add maps import to mq.go
- Replace manual for loop copying payload map with maps.Copy in PublishProfileEvent
- Simplify map merging logic while maintaining same functionality
2026-04-29 13:23:41 +03:00
nutcas3 ccb2ab7ee8 refactor: Add comprehensive documentation with examples to charging-engine modules
- Add module-level documentation to lib.rs with usage example
- Document Claims and AuthConfig structs with examples in auth.rs
- Add ChargingEngine struct documentation with initialization example
- Document ChargingRule, SubscriberAccount, AccountStatus, UsageEvent, UsageType, and RatingPlan with examples in types.rs
- Add CircuitState, CircuitBreakerError, and CircuitBreaker documentation with examples in circuit_breaker.rs
2026-04-29 04:36:40 +03:00
nutcas3 8fddb29716 refactor: Replace fmt.Printf with structured logging using logrus in api-server subscriber and invoice services
- Add logrus import to invoice.go, subscriber_crud.go, subscriber_esim.go, and subscriber_lifecycle.go
- Replace fmt.Printf with logrus.WithError and WithField for structured error logging
- Update invoice email notification placeholder to use logrus.Info with invoice_id field
- Replace eSIM provisioning error print with logrus.Warn including subscriber_id field
- Add comment explaining derived
2026-04-29 04:36:02 +03:00
nutcas3 f15f43e08b feat: Add rustfmt configuration and enhance workspace linting rules
- Add .rustfmt.toml with comprehensive formatting rules for consistent code style
- Set max_width to 100 and tab_spaces to 4 with edition "2026"
- Enable import reordering and grouping with StdExternalCrate strategy
- Configure comment wrapping at 80 characters and enable comment normalization
- Enable field init shorthand, try shorthand, and format code in doc comments
- Set trailing comma to "Vertical" and match_block_trailing_comma to true
2026-04-29 04:35:42 +03:00
nutcas3 b4e42d7717 refactor: Improve Redis key consistency and add existence check in credit management
- Change Redis key prefix from "block:" to "blocked:" in unblock_user for consistency
- Replace is_some() check with if let pattern in block_user to avoid unused variable
- Add existence check before attempting to delete blocked user key in unblock_user
- Use if let pattern for blocked status check in unblock_user
- Return Ok(()) silently if user is not blocked instead of attempting deletion
2026-04-29 04:24:49 +03:00
nutcas3 4008a19f4a refactor: Pre-allocate Vec capacity in rating_billing.rs to reduce reallocations
- Set applied_rules capacity to 6 (maximum number of charging rules that can be applied)
- Set keys capacity to 100 in get_usage_history and get_all_accounts (matches SCAN batch size)
- Add comments explaining capacity choices for each Vec initialization
2026-04-29 04:24:22 +03:00
nutcas3 5ec01e591e refactor: Replace fallback defaults with required environment variable validation in charging-engine auth
- Change AuthConfig::from_env() return type from Self to Result<Self, String>
- Remove default JWT_SECRET fallback, require environment variable to be set
- Add validation requiring JWT_SECRET to be at least 32 characters for security
- Replace expect() with ok_or_else in create_token timestamp calculation
- Replace expect() with map_err in DATABASE_URL environment variable loading
2026-04-29 04:23:58 +03:00
nutcas3 8bb332964b refactor: Replace unwrap() with unwrap_or_else fallback in rate limiter configuration
- Add fallback to default GovernorConfig (10 req/s, burst 20) if custom config fails
- Replace unwrap() with unwrap_or_else providing sensible defaults
- Add comment explaining fallback behavior for rate limiter initialization
2026-04-29 04:23:11 +03:00
nutcas3 5340469a1a refactor: Replace expect() with unwrap_or_else fallbacks and improve error handling in charging-engine
- Remove unused _account variable in calculate_usage_cost
- Replace HashMap::with_capacity with HashMap::new and use iterator chain in get_all_plans
- Add std::process::Command import and set current_dir to repo root in run_migrations
- Add comment explaining directory change to locate migrations folder
- Replace expect() with unwrap_or_else providing fallback JSON in SubscriberAccount and UsageEvent
2026-04-29 04:22:52 +03:00
nutcas3 1deecf32fe refactor: Replace manual Display and Error implementations with thiserror derive macro in ChargingError
- Add thiserror::Error derive to ChargingError enum
- Replace manual fmt::Display implementation with #[error] attributes on each variant
- Remove manual std::error::Error implementation (provided by thiserror)
- Remove std::fmt import as it's no longer needed
- Maintain same error message formats and functionality
2026-04-29 04:22:02 +03:00
nutcas3 4cc0b80b1c refactor: Remove unnecessary clone() calls and improve error handling in packet-gateway
- Remove clone() from rating plan parameter in add_rating_plan call
- Remove clone() calls from ChargingEngineClient and EbpfManager initialization
- Remove clone() from Redis client Arc wrapping
- Remove clone() calls from PacketGatewayConfig field assignments
- Replace expect() with proper error handling using map_err and anyhow in health check server
- Remove clone() from IP string in session data collection
2026-04-29 04:21:52 +03:00
nutcas3 b3ff568bd4 feat: Add workspace-level linting rules and cargo-audit configuration
- Add cargo-audit metadata section with placeholder for ignored advisories
- Forbid unsafe_code at workspace level
- Enable all and pedantic clippy warnings
- Deny unwrap_used, expect_used, and panic to enforce error handling
- Add thiserror dependency to charging-engine for improved error handling
2026-04-29 04:21:33 +03:00
nutcas3 609bdb16fa feat: Set repository root as working directory for Goose migrations in carrier-connector
- Add filepath import for path manipulation
- Calculate repository root path relative to carrier-connector location (../../)
- Set cmd.Dir to repository root before executing Goose command
- Add comment explaining directory change to locate migrations folder
- Ensure migrations can be found from carrier-connector's nested location
2026-04-29 04:21:19 +03:00
nutcas3 898e58201f refactor: Extract CRUD operations from database.go into separate crud.go file
- Move all subscriber, payment method, transaction, and notification CRUD operations to crud.go
- Remove models import from database.go as it's no longer needed
- Keep database initialization, connection management, and IMSI allocation in database.go
- Maintain ListSubscribersRequest struct definition in crud.go alongside related functions
2026-04-29 03:36:45 +03:00
nutcas3 393685846c fix: Convert Status field to string in ListSubscribers database request
- Cast req.Status to string when passing to database.ListSubscribersRequest
- Ensure type compatibility between service and database layer status fields
2026-04-29 03:31:29 +03:00
nutcas3 cc2590bb17 fix: Reorder working-directory and env blocks in database migration step for consistency
- Move working-directory after env block in Run database migrations step
- Maintain same functionality while following standard YAML ordering convention
2026-04-29 03:31:21 +03:00
nutcas3 71353fc237 feat: Replace GORM AutoMigrate with Goose CLI migrations in api-server database initialization
- Add os/exec import for running external commands
- Replace AutoMigrate function with runMigrations function using goose postgres command
- Call runMigrations in NewDatabase before initializing IMSI allocation
- Remove PoolStats function and GORM-based schema migration code
- Reorganize database methods with section comments (Subscriber CRUD, Payment methods, Transactions, Additional CRUD, IMSI allocation)
-
2026-04-29 03:31:00 +03:00
nutcas3 e6450f15ad feat: Add comprehensive database schema migrations for all platform tables
- Add subscribers table with IMSI, MSISDN, authentication keys, and eSIM profile fields
- Add service_plans table for data/voice/SMS limits and QoS parameters (ARPA, AMBR)
- Add sessions table for tracking PDU sessions with QoS and usage metrics
- Add usage_records table for billing and charging data
- Add users table with role-based access control fields
- Add roles, permissions, and role_permissions junction table for RBAC
- Add auth
2026-04-29 03:25:28 +03:00
nutcas3 28422fafc1 fix: Standardize migrations directory path and add explicit working-directory in CI workflow
- Change migrations path from './migrations' to 'migrations' in all test jobs
- Add explicit working-directory: . to migration steps for clarity
- Apply changes to api-server-test, charging-engine-test, and packet-gateway-test jobs
2026-04-29 03:18:11 +03:00
nutcas3 96eacf8e77 fix: Add goose to PATH and correct migrations directory path in CI workflow
- Add explicit PATH configuration step to ensure goose binary is accessible after installation
- Fix migrations directory path from 'migrations' to './migrations' in all test jobs
- Apply changes to api-server-test, charging-engine-test, and packet-gateway-test jobs
2026-04-29 03:11:46 +03:00
nutcas3 62ab577e82 Merge branch 'main' of https://github.com/nutcas3/telecom-platform into ci-&migrations 2026-04-29 03:04:59 +03:00
NutcaseandGitHub 0a8f4660ff Merge pull request #14 from nutcas3/upgraded
feat: Add database migration steps to CI and deployment workflows
2026-04-29 03:04:31 +03:00
nutcas3 9c445aa894 Merge branch 'main' of https://github.com/nutcas3/telecom-platform into ci-&migrations 2026-04-29 03:03:23 +03:00
nutcas3 69241334aa feat: Add automatic Goose migration execution on startup in charging-engine RatingPlansRepo
- Add std::process::Command import for running external commands
- Implement run_migrations function to execute goose postgres migrations
- Call run_migrations in RatingPlansRepo::connect before returning repository instance
- Update function comments to reflect automatic migration execution on startup
- Add error handling and output capture for migration failures
- Add tracing log for successful migration
2026-04-29 03:00:28 +03:00
nutcas3 85012f380f feat: Add PostgreSQL service and database migrations to Rust component test jobs in CI workflow
- Upgrade PostgreSQL service from version 15 to 18 in api-server-test job
- Add PostgreSQL 18 service configuration to charging-engine-test and packet-gateway-test jobs
- Configure database health checks with pg_isready command for all Postgres services
- Add goose installation step to charging-engine-test and packet-gateway-test jobs
- Add database migration execution step before running tests in Rust components
2026-04-29 02:58:48 +03:00
nutcas3 0a02fe4e03 feat: Replace custom migration runner with goose CLI and add migration management commands to Makefile
- Replace custom Go migration runner (go run cmd/migrate/main.go) with goose postgres command in db-migrate target
- Add db-migrate-down target for rolling back migrations
- Add db-migrate-status target to show current migration status
- Add db-create-migration target for creating new migration files with NAME parameter validation
- Add db-migrate-rust target for Rust service migrations (uses same
2026-04-29 02:57:50 +03:00