Class: Aikido::Zen::Middleware::CheckAllowedAddresses
- Inherits:
-
Object
- Object
- Aikido::Zen::Middleware::CheckAllowedAddresses
- Defined in:
- lib/aikido/zen/middleware/check_allowed_addresses.rb
Overview
Middleware that rejects requests from IPs blocked in the Aikido dashboard.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config: Aikido::Zen.config, settings: Aikido::Zen.runtime_settings) ⇒ CheckAllowedAddresses
constructor
A new instance of CheckAllowedAddresses.
Constructor Details
#initialize(app, config: Aikido::Zen.config, settings: Aikido::Zen.runtime_settings) ⇒ CheckAllowedAddresses
Returns a new instance of CheckAllowedAddresses.
9 10 11 12 13 |
# File 'lib/aikido/zen/middleware/check_allowed_addresses.rb', line 9 def initialize(app, config: Aikido::Zen.config, settings: Aikido::Zen.runtime_settings) @app = app @config = config @settings = settings end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aikido/zen/middleware/check_allowed_addresses.rb', line 15 def call(env) request = request_from(env) allowed_ips = @settings.endpoints[request.route].allowed_ips if allowed_ips.empty? || allowed_ips.include?(request.ip) @app.call(env) else @config.blocked_ip_responder.call(request) end end |