Terapkan CAPTCHA pada Login & Endpoint Auth untuk Batasi Bot/Bruteforce#976
Open
pandigresik wants to merge 4 commits intorilis-devfrom
Open
Terapkan CAPTCHA pada Login & Endpoint Auth untuk Batasi Bot/Bruteforce#976pandigresik wants to merge 4 commits intorilis-devfrom
pandigresik wants to merge 4 commits intorilis-devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Perbaikan issue #969
Ada penambahan package dan migrasi
composer installphp artisan migrateCaptcha bisa diatur melalui pengaturan setting, jadi lebih flexible termasuk batas kesalahan sehingga mengharuskan pengguna input captcha.
Setelah captcha tampil, otomatis akan tetap tampil jika masih dalam waktu yang ditentukan dalam RATE_LIMITER_DECAY_MINUTES, otomatis akan hilang jika sudah kadaluarsa
📊 SUMMARY REVIEW: PERUBAHAN TEST DARI DEV-957 KE DEV-969
Review Date: Senin, 9 Maret 2026
Branch Comparison: dev-957 → dev-969
Reviewer: AI Assistant
Status: ✅ APPROVED - Ready for Merge
📋 RINGKASAN EKSEKUTIF
📁 FILE YANG BERUBAH
1. tests/Feature/LoginControllerTest.php
2. tests/Feature/OtpLoginControllerTest.php
🔍 DETAIL PERUBAHAN PER FILE
📄 1. LoginControllerTest.php
A. Struktur Class & Dependencies
Perubahan Penting:
Tests\TestCase(bukanBaseTestCase)Hashfacade untuk password hashingRateLimiteruntuk rate limiting managementB. Setup Method
Perubahan Penting:
User::create()dengan delete firstTestP@ssw0rd123!(strong password)with()clauseC. Test Methods - Perbandingan Detail
Test 1:
it_shows_login_form()✅ BARU - Tidak ada di dev-957
Test 2:
it_can_login_with_email()Perubahan vs Dev-957:
with()clauseassertStatus(302)Test 3:
it_redirects_to_password_change_when_password_is_weak()Best Practice:
Test 4:
it_locks_account_after_max_failed_attempts()Alasan Skip:
D. TearDown Method
Best Practice:
📄 2. OtpLoginControllerTest.php
A. Struktur Class & Dependencies
B. Setup Method
Perubahan Penting:
C. Test Methods Highlights
Test:
it_can_send_otp_with_email_identifier()✅ BARU - Test OTP send functionality
Test:
it_can_verify_otp_and_login()Alasan Skip:
📊 STATISTIK PERUBAHAN
Coverage Test
Test Distribution
🎯 BEST PRACTICES YANG DITERAPKAN
1. Password Security ✅
2. Clean Test State ✅
3. Rate Limiter Management ✅
4. Mock Pattern ✅
5. Skipped Tests Documentation ✅
1.
it_locks_account_after_max_failed_attempts()2.
it_can_verify_otp_and_login()3.
it_redirects_to_2fa_after_otp_verification_when_2fa_enabled()4.
it_resets_failed_attempts_on_successful_otp_verification()✅ KESIMPULAN
Perubahan Major:
with()clause untuk objectsKualitas Test:
Rekomendasi Future Improvements:
🔐 ATURAN CAPTCHA INPUT
A. Kapan Captcha Ditampilkan?
Captcha TIDAK selalu ditampilkan di form login. Captcha hanya muncul ketika:
Threshold Gagal Login Tercapai
Captcha Diaktifkan di Database
captcha.enabled = truedi databaseenabled = false, captcha tidak akan ditampilkan berapapun gagal loginRate Limiter Key Format
B. Jenis Captcha yang Didukung
C. Konfigurasi Captcha di Database
[ 'enabled' => true, // Enable/disable captcha 'type' => 'builtin', // 'builtin' atau 'google' 'threshold' => 3, // Jumlah gagal login sebelum captcha muncul ]D. Test Captcha di LoginControllerTest
Test 1: Show Login Form WITHOUT Captcha
✅ Expected: Form login tampil tanpa captcha (threshold belum tercapai)
Test 2: Show Login Form WITH Captcha
✅ Expected: Form login tampil DENGAN captcha setelah 3 failed attempts
Test 3: Validate Captcha When Required
✅ Expected: Validation error untuk captcha jika tidak diisi
E. Flow Captcha di Login
F. Rate Limiter Decay Time
Implikasi:
G. Best Practice Test Captcha
simplescreenrecorder-2026-03-09_10.02.55.mp4
simplescreenrecorder-2026-03-09_10.44.24.mp4