Authentication & Authorization
Sistem autentikasi dengan JWT, Google Sign-In, dan Apple Sign-In๐ฏ Overview
Authentication adalah salah satu fitur utama dalam MStore Mobile yang menyediakan fungsionalitas untuk sistem autentikasi dengan jwt, google sign-in, dan apple sign-in.๐ Features
- โ Email/Password login
- โ Google Sign-In
- โ Apple Sign-In
- โ JWT token management
- โ Auto token refresh
- โ Biometric authentication
- โ Role-based access control (RBAC)
๐๏ธ Architecture
BLoC Implementation
BLoC:AuthBloc
Repository Pattern
๐ก API Integration
Endpoints
/api/v1/auth/login/api/v1/auth/refresh-token/api/v1/auth/register-device
Request/Response Examples
Get List
๐พ Local Database (Isar)
Schema
ConfigLocal (tokens)
Queries
๐ Offline-First Strategy
Write Operations
- Save to local Isar immediately
- Show success to user
- Add to sync queue
- Background sync when online
- Update with server response
Read Operations
- Read from local Isar (fast)
- Show to user immediately
- Background fetch from API
- Update local cache if changed
- Notify UI if data updated
Conflict Resolution
- Strategy: Last-write-wins
- Timestamp: Server timestamp as source of truth
- Logging: All conflicts logged for audit
๐จ UI Components
Main Screen
๐งช Testing
Unit Tests
๐ Performance Considerations
- Lazy Loading: Load data on demand
- Pagination: Implement pagination for large datasets
- Caching: Cache frequently accessed data
- Indexing: Use Isar indexes for fast queries
- Background Sync: Sync in background to avoid blocking UI
๐ Security
- Authorization: Check user permissions before operations
- Data Encryption: Sensitive data encrypted in Isar
- Input Validation: Validate all user inputs
- Audit Trail: Log all operations for audit
๐ฑ Platform-Specific
iOS
- Use Cupertino widgets
- Follow iOS HIG
- Handle safe area insets
Android
- Use Material widgets
- Follow Material Design
- Handle back button
๐ Related Documentation
Last Updated: October 14, 2024
Status: โ Production Ready