Skip to content

Feature/rack attack #252

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

Merged
merged 32 commits into from
May 14, 2025
Merged

Feature/rack attack #252

merged 32 commits into from
May 14, 2025

Conversation

srappel
Copy link
Member

@srappel srappel commented May 7, 2025

Summary

This PR adds request throttling and Redis-backed caching to the application using the rack-attack gem. It also updates cache configurations in both development and production environments to use Redis.

Changes Included

  • Added rack-attack to the Gemfile.
  • Throttles requests at 200 per IP every 5 minutes.
  • Returns a custom 503 response for throttled requests.
  • Switched from :memory_store to :redis_cache_store in both development.rb and production.rb.
  • Configured Redis URL via ENV["REDIS_URL"], with fallback to redis://localhost:6379/1.
  • "geodiscovery" namespace for Rails caching

Files Modified

  • Gemfile, Gemfile.lock: Added rack-attack gem; retained rack at 3.1.14.
  • config/environments/development.rb: Updated cache store to use Redis.
  • config/environments/production.rb: Same as above.
  • config/initializers/rack_attack.rb: New initializer defining throttling rules and custom response.
  • added test/rack_attack_test.rb to verify Rack::Attack throttling returns a 503 response after exceeding the request limit.

Notes

Redis must be available in each environment, and REDIS_URL should be set accordingly.

This lays the foundation for future bot mitigation and abuse protection strategies.

srappel and others added 26 commits May 5, 2025 15:32
Bumps [redis](https://github.com/redis/redis-rb) from 5.3.0 to 5.4.0.
- [Changelog](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md)
- [Commits](redis/redis-rb@v5.3.0...v5.4.0)

---
updated-dependencies:
- dependency-name: redis
  dependency-version: 5.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ed25519](https://github.com/RubyCrypto/ed25519) from 1.3.0 to 1.4.0.
- [Changelog](https://github.com/RubyCrypto/ed25519/blob/main/CHANGES.md)
- [Commits](RubyCrypto/ed25519@v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: ed25519
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [solr_wrapper](https://github.com/cbeer/solr_wrapper) from 4.1.0 to 4.1.3.
- [Commits](cbeer/solr_wrapper@v4.1.0...v4.1.3)

---
updated-dependencies:
- dependency-name: solr_wrapper
  dependency-version: 4.1.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [exception_notification](https://github.com/kmcphillips/exception_notification) from 4.5.0 to 5.0.0.
- [Release notes](https://github.com/kmcphillips/exception_notification/releases)
- [Changelog](https://github.com/kmcphillips/exception_notification/blob/main/CHANGELOG.rdoc)
- [Commits](kmcphillips/exception_notification@v4.5.0...v5.0.0)

---
updated-dependencies:
- dependency-name: exception_notification
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
…apper-4.1.3

Bump solr_wrapper from 4.1.0 to 4.1.3
…on_notification-5.0.0

Bump exception_notification from 4.5.0 to 5.0.0
Bumps [kredis](https://github.com/rails/kredis) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/rails/kredis/releases)
- [Commits](rails/kredis@v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: kredis
  dependency-version: 1.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@srappel srappel marked this pull request as ready for review May 9, 2025 14:28
@srappel srappel merged commit 7740e48 into main May 14, 2025
3 checks passed
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.

1 participant