Security/rate limiting proxy support#1478
Open
Revanza1106 wants to merge 7 commits intoOpenSID:devfrom
Open
Conversation
- Detects real IP from CF-Connecting-IP, X-Forwarded-For, X-Real-IP - Validates IP format to prevent header injection - Filters private IPs (configurable) - Generates rate limit keys with IP+Email combination Closes OpenSID#1410
- Add configurable trusted proxies via env variable - Support Cloudflare, reverse proxy, load balancer Closes OpenSID#1410
- Login rate limiter: 10 attempts per minute per IP+Email - OTP rate limiter: 3 attempts per minute per IP+Email - Use IpAddress helper for real IP detection Closes OpenSID#1410
- Add throttle:login to POST /login - Add throttle:login to 2FA verify-login - Add throttle:otp to OTP request/resend routes Closes OpenSID#1410
- TRUST_PROXIES for trusted proxy configuration - RATE_LIMIT_LOGIN_MAX and _DECAY - RATE_LIMIT_OTP_MAX and _DECAY Closes OpenSID#1410
- IP detection tests (8 tests) - Rate limit key generation tests (3 tests) - Login rate limiting tests (3 tests) - OTP rate limiting tests (2 tests) - Security validation tests (2 tests) - Priority order tests (2 tests) Total: 20 tests Closes OpenSID#1410
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.
Deskripsi
Menambahkan rate limiting pada endpoint login dan OTP untuk mencegah brute force attack. Implementasi mendukung aplikasi yang berada di belakang Cloudflare Proxy atau Reverse Proxy dengan deteksi IP asli dari header proxy.
Fitur Utama
CF-Connecting-IP,X-Forwarded-For,X-Real-IPPerubahan File
app/Helpers/IpAddress.php(baru) - Helper deteksi IP proxyapp/Http/Middleware/TrustProxies.php- Konfigurasi trusted proxyapp/Providers/RouteServiceProvider.php- Rate limiter login/OTProutes/web.php- Apply throttle middleware.env.example- Konfigurasi env variablestests/Feature/RateLimitingTest.php- Test suite (20 test cases)Masalah Terkait (Related Issue)
Langkah untuk mereproduksi (Steps to Reproduce)
Sebelum Perubahan (Bug Reproduction)
/loginSetelah Perubahan (Verification)
/loginCF-Connecting-IP: IP terdeteksi dengan benarManual Test Command
Hasil Test
Automated Test (Pest)
Test Coverage Summary
Daftar Periksa (Checklist)
Tangkapan Layar (Screenshot)
Test Results
Konfigurasi Environment
Tambahkan ke
.env:Commit Breakdown