Rate-limit the public, unauthenticated write endpoints
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu với bốn action create được nêu tên: PublicFormsController#create, Events::PublicRegistrationsController#create, Events::BulkPaymentFormSubmissionsController#create và ContactUsController#create. Thêm các giới hạn tốc độ Rails được mô tả cho từng endpoint, sau đó xác minh giới hạn theo cách thủ công trong môi trường development bằng memory cache; đồng thời xác nhận rằng request.remote_ip hoạt động chính xác phía sau production proxy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Four endpoints accept unauthenticated POSTs and create records / send email. None are throttled — the only defence is a hidden honeypot field, which stops naive bots but nothing deliberate.
Endpoints
| Endpoint | Controller | Creates |
|---|---|---|
POST /f/:slug |
PublicFormsController#create |
Person, FormSubmission, 2 emails |
POST /events/:event_id/public_registrations |
Events::PublicRegistrationsController#create |
Person, EventRegistration, FormSubmission, emails |
POST /events/:event_id/bulk_payment_form_submissions |
Events::BulkPaymentFormSubmissionsController#create |
Person, FormSubmission, emails |
POST /contact_us |
ContactUsController#create |
/f/:slug is the most exposed: it is always open, whereas the event endpoints are gated behind ensure_registerable.
Approach
Rails 8.1 ships ActionController::RateLimiting, so no new gem:
rate_limit to: 5, within: 1.minute, only: :create,
with: -> { redirect_to public_form_path(@form.slug), alert: "Too many submissions — please wait a minute." }
Keys on request.remote_ip by default and scopes per controller.
Storage
Uses config.cache_store, which is already suitable in both real environments:
- production —
:solid_cache_store(DB-backed, so the counter is shared across processes) - development —
:memory_store
Decided: no spec for the rate limit
Test env is :null_store, so increment no-ops and a limit never trips — it can't be spec'd without first changing the test cache store (stub Rails.cache, pass an explicit store:, or switch the env to :memory_store).
We are deliberately not doing that. Writing the spec means solving the cache-store question and adds roughly 15 minutes to every suite run for a one-line, framework-provided guard. Not worth it. Ship the rate_limit calls unspec'd and verify by hand in development (where :memory_store makes the limit live).
Revisit only if a future limit carries real logic in its by: or with: lambda.
Notes
- Confirm
request.remote_ipresolves correctly behind the production proxy before trusting per-IP keys. - Deliberately scoped as its own PR rather than folded into #2237: this is a cross-cutting policy that should cover all four endpoints at once.
- Ngôn ngữ chính
- Ruby
- Star
- 15
- Fork
- 28
- Merge trung bình
- 1 ngày 12 phút
- Pull request đã merge (30 ngày)
- 262
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rubyforgood/awbw
-
blocked
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
rubyforgood/awbw#2824 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rubyforgood/awbw#2822 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rubyforgood/awbw#2160 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update callout faq defualt text when the new person subscription launchesCó thể đã có người làm @maebeale đã nhận 79 ngày trước. Đang mởblocked
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rubyforgood/awbw#2095 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
rubyforgood/awbw#2088 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rubyforgood/awbw
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
L: javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dependabot/dependabot-core#16744 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:core-lib P2 size:S
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày