forest_admin_agent 1.0.0.pre.beta.45 → 1.0.0.pre.beta.47

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d61e45333bea735ec3c47b19b761f8081bc6bf3cb7e78f2df61ed43eecf4ce9
4
- data.tar.gz: 833560b6f78019008a1f7c8dd8a640b65cb1870ae7f341a10d22986d244bc300
3
+ metadata.gz: 56cd6d9f71a53bee234570bccd942191684758b3a0b261549c8cf504f02d7b64
4
+ data.tar.gz: 5e1ef6098d3e45feccf9e521a4e1ee0684a76eaa0c7b19fcd3a09a1a565604b1
5
5
  SHA512:
6
- metadata.gz: 00a941a6b5c3417233a5a141451d145282e4a1dd6765dd782742d886ed8f10eadea02cdcb92285f614f6c04deb6b1359a43ba2ae2f286f110bde6f8ebf717d04
7
- data.tar.gz: 07db816bfdc85d3228f11515a4e9ba56be78425b6cba049176f837c72e3555cc325cc5481409ef302eadc81781efcad44d9648a1dcc7e363df39ab2cd3eef12e
6
+ metadata.gz: 34525c9a9648c71da21fd815b4a16608db211fc897fbe8def79445c3d800b56ac6339f8a3e6e4ae6f9b5043da9c735bd5c3ebd4fed434dc7c279dc6781531c3c
7
+ data.tar.gz: 1fd874f037ef715a8f1f8cc9a887abc97311c304c5171c37a94f6b9499cb5fc8b1d57d3fcfca6734f3b129d91a1af2dfebe8b1231d6a747feada2ff7b4a026da
@@ -9,6 +9,12 @@ module ForestAdminAgent
9
9
  TTL = 60 * 60 * 24
10
10
 
11
11
  def make_forest_provider(rendering_id)
12
+ if Facades::Container.cache(:debug)
13
+ OpenIDConnect.http_config do |options|
14
+ options.ssl.verify = false
15
+ end
16
+ end
17
+
12
18
  config_agent = Facades::Container.config_from_cache
13
19
  cache_key = "#{config_agent[:env_secret]}-client-data"
14
20
  cache = setup_cache(cache_key, config_agent)
@@ -13,7 +13,8 @@ module ForestAdminAgent
13
13
  @client = Faraday.new(
14
14
  Facades::Container.cache(:forest_server_url),
15
15
  {
16
- headers: @headers
16
+ headers: @headers,
17
+ ssl: { verify: !Facades::Container.cache(:debug) }
17
18
  }
18
19
  )
19
20
  end
@@ -1,5 +1,4 @@
1
1
  require 'ipaddress'
2
- require 'net/http'
3
2
 
4
3
  module ForestAdminAgent
5
4
  module Services
@@ -8,15 +7,19 @@ module ForestAdminAgent
8
7
  RULE_MATCH_RANGE = 1
9
8
  RULE_MATCH_SUBNET = 2
10
9
 
10
+ attr_reader :forest_api
11
+
11
12
  def initialize
12
- fetch_rules
13
+ @forest_api = ForestAdminAgent::Http::ForestAdminApiRequester.new
13
14
  end
14
15
 
15
16
  def use_ip_whitelist
17
+ fetch_rules if @use_ip_whitelist.nil?
16
18
  @use_ip_whitelist ||= false
17
19
  end
18
20
 
19
21
  def rules
22
+ fetch_rules if @rules.nil?
20
23
  @rules ||= []
21
24
  end
22
25
 
@@ -82,18 +85,15 @@ module ForestAdminAgent
82
85
  private
83
86
 
84
87
  def fetch_rules
85
- response = Net::HTTP.get_response(
86
- URI("#{Facades::Container.cache(:forest_server_url)}/liana/v1/ip-whitelist-rules"),
87
- { 'Content-Type' => 'application/json', 'forest-secret-key' => Facades::Container.cache(:env_secret) }
88
- )
89
-
90
- raise Error, ForestAdminAgent::Utils::ErrorMessages::UNEXPECTED unless response.is_a?(Net::HTTPSuccess)
88
+ response = forest_api.get('/liana/v1/ip-whitelist-rules')
91
89
 
92
90
  body = JSON.parse(response.body)
93
91
  ip_whitelist_data = body['data']['attributes']
94
92
 
95
93
  @use_ip_whitelist = ip_whitelist_data['use_ip_whitelist']
96
94
  @rules = ip_whitelist_data['rules']
95
+ rescue StandardError
96
+ raise Error, ForestAdminAgent::Utils::ErrorMessages::UNEXPECTED
97
97
  end
98
98
  end
99
99
  end
@@ -106,15 +106,24 @@ module ForestAdminAgent
106
106
  end
107
107
 
108
108
  def self.parse_sort(collection, args)
109
- sort_string = args.dig(:params, :sort)
109
+ raw_sort_string = args.dig(:params, :sort)
110
110
 
111
- return SortUtils::SortFactory.by_primary_keys(collection) unless sort_string
111
+ return SortUtils::SortFactory.by_primary_keys(collection) unless raw_sort_string
112
112
 
113
- sort = Sort.new([
114
- { field: sort_string.gsub(/^-/, '').tr('.', ':'), ascending: !sort_string.start_with?('-') }
115
- ])
113
+ sort_list = []
114
+ raw_sort_string.split(',').map do |sort_string|
115
+ field = sort_string.tr('.', ':')
116
+ ascending = !sort_string.start_with?('-')
117
+ field = field[1..] unless ascending
118
+
119
+ sort_list.push({ field: field, ascending: ascending })
120
+ end
121
+
122
+ sort = Sort.new(sort_list)
116
123
 
117
124
  ForestAdminDatasourceToolkit::Validations::SortValidator.validate(collection, sort)
125
+
126
+ sort
118
127
  end
119
128
  end
120
129
  end
@@ -7,7 +7,7 @@ module ForestAdminAgent
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "forest-rails"
9
9
 
10
- LIANA_VERSION = "1.0.0-beta.45"
10
+ LIANA_VERSION = "1.0.0-beta.47"
11
11
 
12
12
  def self.get_serialized_schema(datasource)
13
13
  schema_path = Facades::Container.cache(:schema_path)
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.0.0-beta.45"
2
+ VERSION = "1.0.0-beta.47"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.45
4
+ version: 1.0.0.pre.beta.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-05-03 00:00:00.000000000 Z
12
+ date: 2024-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport