4 Commits

Author SHA1 Message Date
admin 29cf10c379 fixed region fetching in user_attributes 2026-04-16 13:42:50 +08:00
admin ae1831e61f feat: standardize field names and add flexible role_id handling for JWT compatibility
- Rename user_id → users_id across all models, handlers, services, and tests
- Add custom RoleIDs type supporting string/int/array unmarshaling (e.g., "1", 1, [1])
- Implement flexible JSON unmarshaling for JWT Claims to handle field name variants
  - Support both user_id/users_id and email/email_address field names
  - Enable role_id as string ("1"), int (1), or array ([1,2])
- Update AuthorizationContext to handle role_id type flexibility
- Add comprehensive logging to repository, service, and handler layers
  - Entry/exit logs with full context
  - Success (✓) and failure (✗) indicators
  - Step-by-step authorization flow tracking
- Add containsRole helper for multi-role membership checks
- Fix database queries: user_id → users_id, id → permissions_id
- Update all tests to use models.RoleIDs{} syntax
- Change GetRole middleware return type: string → []int
- Maintain backward compatibility with legacy JWT tokens

This change improves integration with external services (MIS) that may send
role_id in different formats and standardizes field naming conventions
throughout the authorization microservice.
2026-02-03 16:35:16 +08:00
admin 2f2e44d6fc fix: enable all skipped tests and resolve critical logic issues
- Remove all t.Skip() calls (22+ tests) and implement proper mocking
- Fix impossible nil check causing compiler warning in error_logging_test
- Make rate limiter fail-open consistently when Redis unavailable
- Add case sensitivity documentation to policy comparison operators
- Update repository tests with correct SQL query expectations
- Make tests handle DB/Redis unavailability gracefully without panics
2025-12-16 13:55:27 +08:00
admin 0d8f5b9600 feat: implement horizontal scaling optimizations for authz service
- Add /health and /ready endpoints for load balancer health checks
- Replace in-memory JWT token cache with Redis for multi-replica support
- Reduce DB connection pool from 100 to 25 connections per replica
- Add distributed rate limiting (100 req/min + 20 burst) using Redis
- Implement circuit breakers for DB and Redis to prevent cascading failures

This enables the service to scale horizontally with multiple replicas
behind a load balancer without exhausting database connections or
maintaining separate token caches per instance.
2025-12-16 10:03:18 +08:00