gab-social/config/initializers/rack_attack.rb
mgabdev 7c6ef8bb9d Removed some Rack configs and moved RackAttack rate limits, headers
• Removed:
- some Rack configs and moved RackAttack rate limits, headers
2021-01-14 13:37:38 -05:00

22 lines
625 B
Ruby

# frozen_string_literal: true
require 'doorkeeper/grape/authorization_decorator'
class Rack::Attack
class Request
def remote_ip
# @remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s
# @env['HTTP_CF_CONNECTING_IP'] ? @env['HTTP_CF_CONNECTING_IP'] : ip
@remote_ip ||= (@env["HTTP_CF_CONNECTING_IP"] || ip).to_s
end
end
# Always allow requests from localhost
# (blocklist & throttles are skipped)
Rack::Attack.safelist('allow from localhost') do |req|
# Requests are allowed if the return value is truthy
req.remote_ip == '127.0.0.1' || req.remote_ip == '::1'
end
end