11 Commits

Author SHA1 Message Date
admin f0bc603a5f fixed region fetching in user_attributes 2026-03-24 16:38:41 +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 d5606b34f9 fixed ABAC 2026-01-29 11:43:22 +08:00
admin bd0fdf89f3 fix test files 2026-01-27 10:45:15 +08:00
admin 8b589e5a55 added skipping of policy evaluation for super and system admin 2026-01-27 10:13:50 +08:00
admin 71923eb634 add unresolved placeholders 2026-01-27 10:13:15 +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 ee8079e65c changed icon of passed 2025-12-15 14:32:42 +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