Class: Aikido::Zen::RuntimeSettings::ProtectionSettings
- Inherits:
-
Object
- Object
- Aikido::Zen::RuntimeSettings::ProtectionSettings
- Defined in:
- lib/aikido/zen/runtime_settings/protection_settings.rb
Overview
Models the settings for a given Route as configured in the Aikido UI.
Instance Attribute Summary collapse
-
#allowed_ips ⇒ Aikido::Zen::RuntimeSettings::IPSet
readonly
List of IP addresses which are allowed to make requests on this route.
- #rate_limiting ⇒ Aikido::Zen::RuntimeSettings::RateLimitSettings readonly
Class Method Summary collapse
-
.from_json(data) ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
Initialize settings from an API response.
-
.none ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
Singleton instance for endpoints with no configured protections on a given route, that can be used as a default value for routes.
Instance Method Summary collapse
-
#initialize(protected: true, allowed_ips: RuntimeSettings::IPSet.new, rate_limiting: RuntimeSettings::RateLimitSettings.disabled) ⇒ ProtectionSettings
constructor
A new instance of ProtectionSettings.
- #protected? ⇒ Boolean
Constructor Details
#initialize(protected: true, allowed_ips: RuntimeSettings::IPSet.new, rate_limiting: RuntimeSettings::RateLimitSettings.disabled) ⇒ ProtectionSettings
Returns a new instance of ProtectionSettings.
48 49 50 51 52 53 54 55 56 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 48 def initialize( protected: true, allowed_ips: RuntimeSettings::IPSet.new, rate_limiting: RuntimeSettings::RateLimitSettings.disabled ) @protected = !!protected @rate_limiting = rate_limiting @allowed_ips = allowed_ips end |
Instance Attribute Details
#allowed_ips ⇒ Aikido::Zen::RuntimeSettings::IPSet (readonly)
Returns list of IP addresses which are allowed to make requests on this route. If empty, all IP addresses are allowed.
43 44 45 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 43 def allowed_ips @allowed_ips end |
#rate_limiting ⇒ Aikido::Zen::RuntimeSettings::RateLimitSettings (readonly)
46 47 48 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 46 def rate_limiting @rate_limiting end |
Class Method Details
.from_json(data) ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
Initialize settings from an API response.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 29 def self.from_json(data) ips = RuntimeSettings::IPSet.from_json(data["allowedIPAddresses"]) rate_limiting = RuntimeSettings::RateLimitSettings.from_json(data["rateLimiting"]) new( protected: !data["forceProtectionOff"], allowed_ips: ips, rate_limiting: rate_limiting ) end |
.none ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
Returns singleton instance for endpoints with no configured protections on a given route, that can be used as a default value for routes.
12 13 14 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 12 def self.none @no_settings ||= new end |
Instance Method Details
#protected? ⇒ Boolean
58 59 60 |
# File 'lib/aikido/zen/runtime_settings/protection_settings.rb', line 58 def protected? @protected end |