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 gem #206

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gem "jwt"
gem "newrelic_rpm"
gem "open-uri"
gem "puma"
gem "rack-attack"
gem "rack-cors"
gem "shrine"
gem "sidekiq"
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ GEM
database_cleaner-active_record (1.8.0)
activerecord
database_cleaner (~> 1.8.0)
date (3.2.1)
date (3.2.2)
declarative (0.0.20)
diff-lcs (1.3)
docile (1.3.2)
Expand Down Expand Up @@ -133,7 +133,7 @@ GEM
faraday-net_http_persistent (1.0.3)
net-http-persistent (>= 3.1)
ffaker (2.14.0)
ffi (1.12.2)
ffi (1.15.5)
gems (1.2.0)
globalid (1.0.0)
activesupport (>= 5.0)
Expand Down Expand Up @@ -229,6 +229,8 @@ GEM
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack-attack (6.6.0)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-test (1.1.0)
Expand Down Expand Up @@ -388,6 +390,7 @@ DEPENDENCIES
open-uri
pg
puma
rack-attack
rack-cors
rails (~> 6.0.4.6)
rspec-rails
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Rack
class Attack
throttle("req/ip", limit: 300, period: 5.minutes, &:ip)
end
end
8 changes: 4 additions & 4 deletions spec/acceptance/authentication_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
let!(:user) { create :user, id: 111_111 }
let(:query) do
<<-GRAPHQL
query {
me {
id
query {
me {
id
}
}
}
GRAPHQL
end

Expand Down