Authentication Flow
Dokumentasi lengkap tentang alur autentikasi di MStore Dashboard, termasuk login, token refresh, dan logout.Overview
MStore Dashboard menggunakan JWT authentication dengan strategi keamanan tinggi:- Access Token: Disimpan di memory (Pinia store)
- Refresh Token: HttpOnly cookie (set oleh backend)
Login Flow
Login Implementation
Token Refresh Flow
Token Refresh Implementation
Logout Flow
Logout Implementation
Route Protection Flow
Route Guard Implementation
Session Recovery Flow
Session Recovery Implementation
Complete Auth State Machine
Security Considerations
Token Storage
Token Storage
- Access Token: Memory only (not localStorage)
- Refresh Token: HttpOnly cookie
- Never expose tokens to JavaScript
Token Lifetime
Token Lifetime
- Access Token: 15-30 minutes
- Refresh Token: 7-30 days
- Auto-refresh before expiration
HTTPS Only
HTTPS Only
- All auth requests over HTTPS
- Secure flag on cookies
- SameSite=Strict atau Lax
CSRF Protection
CSRF Protection
- Refresh token dalam HttpOnly cookie
- Origin validation di backend
- SameSite cookie attribute
Error Handling
| Error | User Action | System Action |
|---|---|---|
| Invalid credentials | Show error message | Clear form |
| Token expired | None (auto-refresh) | Refresh token |
| Refresh failed | Redirect to login | Clear all tokens |
| Network error | Show retry option | Retry with backoff |
| Account locked | Show support contact | Log attempt |