Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Rate-limit the public, unauthenticated write endpoints

Đang mở
#2,252 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rails, ruby
Lĩnh vực
backend, security

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ả

enhancement

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 email

/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_ip resolves 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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rubyforgood/awbw

Tất cả issue của rubyforgood/awbw

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.