SEC-B4
✓ Fully Implemented
Logging In, Logging Out Securely & Resetting a Forgotten Password
Step-by-step instructions for logging into Kariahku.com, brute-force rate limiting rules, secure POST+CSRF logout, and resetting a forgotten password.
Step-by-Step Instructions
1. Logging Into the System (/login)
- Click Log In in the top navigation bar or visit
/{lang}/login. - Enter your registered Email address (up to 254 characters).
- Enter your Password (up to 72 characters).
- Click Log In.
- Upon verification, the system regenerates the PHP session ID (
session_regenerate_id(true)), rotates the CSRF token, writes anauth.loginaudit entry, and redirects to/{lang}/dashboard.
2. Logging Out Securely (/logout)
- Click the Log Out button in the header navigation bar.
- The button submits a CSRF-protected HTTP
POSTrequest to/{lang}/logout(GET requests to/logoutare rejected with405 Method Not Allowedto prevent cross-site logout CSRF). - The session is destroyed, the session cookie is expired, an
auth.logoutevent is logged, and you are redirected to/{lang}/login.
3. Resetting a Forgotten Password (/forgot-password & /reset-password)
- On
/login, click Forgot password? to open/{lang}/forgot-password. - Enter your registered Email address and click Submit.
- The system generates a 64-character hex reset token (stored as a SHA-256 hash in
password_resetsvalid for 1 hour). - Open the reset URL
/{lang}/reset-password?token={token}. - Enter your new Password (minimum 12 characters, maximum 72 characters) and repeat it in Confirm Password.
- Click Submit. The token is marked used (
used_at) and you are redirected to/login.
Verified Screenshots & UI Reference
Input Fields & Options Reference
| Input Field | Route | Validation Rules |
|---|---|---|
email | /login, /forgot-password | Valid email format, max 254 chars, dir="ltr". |
password | /login, /reset-password | Login: 1–72 chars. Password reset: 12–72 chars required. |
confirm_password | /reset-password | Must exactly match the new password field. |
Expected Results
Users sign in to `/dashboard`, sign out with complete session cleanup, or reset their password securely.
Important Notes & Data Boundaries: Brute-Force Protection: 5 failed login attempts for the same email or IP address within 15 minutes temporarily locks login attempts for 15 minutes.
Common Errors & Troubleshooting
- Login Error ("Invalid email or password"): Verify email spelling, check Caps Lock, ensure your account status is
active, and wait 15 minutes if rate-limited. - Reset Error ("Invalid or expired reset token"): Tokens expire after 60 minutes and are single-use. Request a new token at
/forgot-password(throttled to 1 request per 60 seconds).