Class: ActionHook::Core::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/actionhook/core/configuration.rb

Constant Summary collapse

DEFAULT_OPEN_TIMEOUT_IN_SECONDS =
5
DEFAULT_READ_TIMEOUT_IN_SECONDS =
15
DEFAULT_HASH_HEADER_NAME =
'SHA256-FINGERPRINT'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_timeout: DEFAULT_OPEN_TIMEOUT_IN_SECONDS, read_timeout: DEFAULT_READ_TIMEOUT_IN_SECONDS, hash_header_name: DEFAULT_HASH_HEADER_NAME, allow_private_ips: false, blocked_custom_ip_ranges: [], ca_file: nil) ⇒ Configuration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/actionhook/core/configuration.rb', line 14

def initialize(open_timeout: DEFAULT_OPEN_TIMEOUT_IN_SECONDS,
  read_timeout: DEFAULT_READ_TIMEOUT_IN_SECONDS,
  hash_header_name: DEFAULT_HASH_HEADER_NAME,
  allow_private_ips: false,
  blocked_custom_ip_ranges: [],
  ca_file: nil
)
  @open_timeout = open_timeout
  @read_timeout = read_timeout
  @hash_header_name = hash_header_name
  @allow_private_ips = allow_private_ips
  @blocked_custom_ip_ranges = blocked_custom_ip_ranges || []
  @ca_file = ca_file
end

Instance Attribute Details

#allow_private_ipsObject

Returns the value of attribute allow_private_ips.



9
10
11
# File 'lib/actionhook/core/configuration.rb', line 9

def allow_private_ips
  @allow_private_ips
end

#blocked_custom_ip_rangesObject



37
38
39
# File 'lib/actionhook/core/configuration.rb', line 37

def blocked_custom_ip_ranges
  @memoized_blocked_custom_ip_ranges ||= @blocked_custom_ip_ranges&.map{|ip| IPAddr.new(ip)} || []
end

#ca_fileObject

Returns the value of attribute ca_file.



9
10
11
# File 'lib/actionhook/core/configuration.rb', line 9

def ca_file
  @ca_file
end

#hash_header_nameObject

Returns the value of attribute hash_header_name.



9
10
11
# File 'lib/actionhook/core/configuration.rb', line 9

def hash_header_name
  @hash_header_name
end

#open_timeoutObject

Returns the value of attribute open_timeout.



9
10
11
# File 'lib/actionhook/core/configuration.rb', line 9

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



9
10
11
# File 'lib/actionhook/core/configuration.rb', line 9

def read_timeout
  @read_timeout
end

Instance Method Details

#allow_all?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/actionhook/core/configuration.rb', line 41

def allow_all?
  allow_private_ips && blocked_custom_ip_ranges.empty?
end

#net_http_optionsObject



29
30
31
32
33
34
35
# File 'lib/actionhook/core/configuration.rb', line 29

def net_http_options
  {
    open_timeout: @open_timeout,
    read_timeout: @read_timeout,
    ca_file: @ca_file
  }.compact
end