24 Commits

Author SHA1 Message Date
admin e6bbaeffa6 feat(authz): redirect deleted accounts to /login
detect soft-deleted users during authorization lookup
return a dedicated deleted-user result from auth services
redirect deleted accounts to /login in the handler
update repository, service, and handler tests for the new flow
2026-05-08 09:04:28 +08:00
admin 29cf10c379 fixed region fetching in user_attributes 2026-04-16 13:42:50 +08:00
admin 8ca995d490 fixed authorization (now checks the role inside of the project) 2026-03-02 13:46:14 +08:00
admin 20bd509bba added additional_role_id when checking the roles 2026-02-27 14:03:29 +08:00
admin 3ac1f83dd4 added more error logs 2026-02-27 10:18:38 +08:00
admin 6262c875b7 feat(authz): support multi-role claim evaluation and role-aware permission checks
Parse and normalize user and project role claims (role_id + projects[].role_id)
Intersect requested roles with JWT-available roles before authorization
Evaluate permissions across candidate roles in both cached and non-cached flows
Fix claim field fallbacks (user_id/email) and role ID log formatting
Update tests and SQL mock expectations for new role-resolution behavior
2026-02-27 08:39:33 +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 3abaf6f592 removed simple check 2026-01-29 09:33:50 +08:00
admin 6d8a2faf25 fixed message 2026-01-27 13:14:22 +08:00
admin c4a7719ca5 setting of context roleid from claims 2026-01-27 10:10:41 +08:00
admin 4c190a2fff added another test 2026-01-27 09:20:05 +08:00
admin 509a502a85 removed username 2026-01-16 10:50:50 +08:00
admin a361140629 fixed 2026-01-05 15:59:13 +08:00
admin fc0825252d added logging 2026-01-05 14:02:57 +08:00
admin 3608bcd148 fixed roleID 2025-12-18 10:24:18 +08:00
admin e6b3e3b3ae fixed sonarqube issues 2025-12-17 09:42:18 +08:00
admin 5828a2ff21 fixed unit testing 2025-12-16 13:26:07 +08:00
admin 7e42d04fde added more comprehensive unit test cases 2025-12-16 11:18:35 +08:00
admin 7d6efecb41 added unit testing 2025-12-16 10:57:26 +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
admin 15deba4584 fixed multiple roles in 1 policy 2025-12-15 13:24:16 +08:00
admin 5743dbf22d fixed authorization 2025-12-09 15:42:35 +08:00
admin ca49e8e24b fix all issues 2025-12-04 10:59:46 +08:00
admin 60992c1e44 init 2025-12-04 10:55:25 +08:00