Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rack::Attack #526

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add Rack::Attack #526

wants to merge 2 commits into from

Conversation

pixeldesu
Copy link
Member

This PR adds, configures and tests Rack::Attack for rate-limiting. Currently only on the /ajax/ask endpoint.

Due to AjaxController sending off it's own responses, this doesn't fully work yet however, because we always return 200 for a successful request, regardless of the middleware saying stuff is throttled or not. This needs a workaround, or needs to wait until #444 is implemented.

Fixes #518

@pixeldesu pixeldesu requested a review from nilsding as a code owner July 17, 2022 13:53
end

describe "throttle_authenticated_asking" do
let (:user) { FactoryBot.create(:user) }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Correctable] Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.


before(:each) do
Rack::Attack.enabled = true
Rack::Attack.reset!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.

@pixeldesu pixeldesu marked this pull request as draft July 17, 2022 13:54
@codecov
Copy link

codecov bot commented Jul 17, 2022

Codecov Report

Merging #526 (f2fbb1c) into main (a5bb4c0) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #526   +/-   ##
=======================================
  Coverage   85.43%   85.43%           
=======================================
  Files         129      129           
  Lines        2396     2396           
=======================================
  Hits         2047     2047           
  Misses        349      349           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5bb4c0...f2fbb1c. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rate limiting
1 participant