6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/services/forest_liana/ip_whitelist.rb', line 6
def self.retrieve
begin
response = ForestLiana::ForestApiRequester.get('/liana/v1/ip-whitelist-rules')
if response.is_a?(Net::HTTPOK)
body = JSON.parse(response.body)
ip_whitelist_data = body['data']['attributes']
@@use_ip_whitelist = ip_whitelist_data['use_ip_whitelist']
@@ip_whitelist_rules = ip_whitelist_data['rules']
true
else
FOREST_LOGGER.error 'An error occured while retrieving your IP whitelist. Your Forest ' +
'env_secret seems to be missing or unknown. Can you check that you properly set your ' +
'Forest env_secret in the forest_liana initializer?'
false
end
rescue => exception
FOREST_REPORTER.report exception
FOREST_LOGGER.error 'Cannot retrieve the IP Whitelist from the Forest server.'
FOREST_LOGGER.error 'Which was caused by:'
ForestLiana::Errors::ExceptionHelper.recursively_print(exception, margin: ' ', is_error: true)
false
end
end
|