feat: popup quảng cáo, đặt lại mật khẩu bằng token 80 ký tự, 2FA email, vá lỗ hổng bảo mật

- Popup/banner quảng cáo cấu hình từ admin (loại, link, lịch hiển thị)
- Đặt lại mật khẩu: token 80 ký tự kèm check digit Luhn thay cho token+email lộ trong URL, chỉ lưu bản băm, một lần dùng, hết hạn 60 phút
- Xác thực 2 lớp qua email khi đăng nhập (mã 6 số, ghi nhớ thiết bị 90 ngày)
- ApiAuthCheck chặn ngay tài khoản bị khoá dù JWT còn hạn (trước đây dùng được tới hết TTL)
- Handler trả 404 thay vì 500 khi ModelNotFoundException không bọc HttpException
- Test ClientTamperingTest: xác nhận IDOR/giả mạo dữ liệu từ client đều bị chặn

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-13 13:23:33 +07:00
co-authored by Claude Sonnet 5
parent e888a6ed5d
commit 12d5b4951c
33 changed files with 1499 additions and 51 deletions
+9
View File
@@ -38,6 +38,7 @@ Route::prefix('v1')
Route::post('refresh', 'refresh')->name('refresh');
Route::post('forgot-password', 'forgotPassword')->middleware(['throttle:client-auth', 'turnstile'])->name('forgot-password');
Route::post('reset-password', 'resetPassword')->middleware(['throttle:client-auth', 'turnstile'])->name('reset-password');
Route::get('reset-password/{token}', 'showResetToken')->middleware('throttle:client-auth')->name('reset-password.show');
// Ảnh CCCD nằm trên disk private, chỉ truy cập qua URL ký (ClientResource cấp, hết hạn 60 phút)
Route::get('cccd/{customer}/{side}', 'cccdImage')
->whereNumber('customer')
@@ -45,6 +46,8 @@ Route::prefix('v1')
->middleware('signed:relative')
->name('cccd');
Route::post('impersonate/exchange', 'impersonateExchange')->name('impersonate.exchange');
Route::post('login/two-factor', 'verifyLoginTwoFactor')->middleware('throttle:client-auth')->name('login.two-factor');
Route::post('login/two-factor/resend', 'resendLoginTwoFactor')->middleware('throttle:client-auth')->name('login.two-factor.resend');
Route::group(['middleware' => ['api.auth']], function () {
Route::get('me', 'me')->name('me');
@@ -54,6 +57,11 @@ Route::prefix('v1')
Route::put('preferences', 'updatePreferences')->name('preferences.update');
Route::post('update-cccd', 'updateCccd')->name('update-cccd');
Route::put('change-password', 'changePassword')->name('change-password');
Route::get('two-factor', 'twoFactorStatus')->name('two-factor.status');
Route::post('two-factor/setup-code', 'sendTwoFactorSetupCode')->middleware('throttle:client-auth')->name('two-factor.setup-code');
Route::post('two-factor/enable', 'enableTwoFactor')->middleware('throttle:client-auth')->name('two-factor.enable');
Route::post('two-factor/disable', 'disableTwoFactor')->middleware('throttle:client-auth')->name('two-factor.disable');
Route::delete('two-factor/devices', 'revokeTrustedDevices')->name('two-factor.devices.revoke');
});
});
@@ -200,6 +208,7 @@ Route::prefix('v1')
Route::get('turnstile', 'getTurnstileSetting')->name('turnstile');
Route::get('menu', 'getMenu')->name('menu');
Route::get('quick-links', 'getQuickLinks')->name('quick-links');
Route::get('popups', 'getPopups')->name('popups');
});
});