forest_admin_agent 1.44.3 → 1.44.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82246fa1590f7e734cedc309c456c3dca128ea82b325c3842ad6fa291a7051cf
|
|
4
|
+
data.tar.gz: 7943c129e8985805327acb63b8f49448ef6fa0a323c501cb420c5030eed514be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa96c5af1acbbaca154093885dcc4336c7e1b699de8854200655e9f10ce62564e09232bdffc71d468f08a61d7169dcb1ad08b2389ae518f32cf1432e716ecfee
|
|
7
|
+
data.tar.gz: 83bfa0a61d14812a660dafdfe2fc8ae8b07856dd7fb58caa6da56215d36e458a69efbc7eaf707bf1fc559416f5decb649b72301673bfbdabea00b4f878a806e7
|
|
@@ -9,6 +9,10 @@ module ForestAdminAgent
|
|
|
9
9
|
include ForestAdminDatasourceToolkit::Exceptions
|
|
10
10
|
include ForestAdminDatasourceToolkit::Components::Query::ConditionTree
|
|
11
11
|
|
|
12
|
+
USERS_RELOAD_INTERVAL_IN_SECONDS = 60
|
|
13
|
+
|
|
14
|
+
@users_reload_mutex = Mutex.new
|
|
15
|
+
|
|
12
16
|
attr_reader :caller, :forest_api, :cache
|
|
13
17
|
|
|
14
18
|
def initialize(caller)
|
|
@@ -28,13 +32,26 @@ module ForestAdminAgent
|
|
|
28
32
|
Facades::Container.config_from_cache[:permission_expiration]
|
|
29
33
|
)
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
if id_cache.nil?
|
|
36
|
+
cache.clear
|
|
37
|
+
@users_reload_mutex.synchronize { @users_reloaded_at = nil }
|
|
38
|
+
end
|
|
32
39
|
|
|
33
40
|
cache.delete(id_cache) unless cache.get(id_cache).nil?
|
|
34
41
|
|
|
35
42
|
ForestAdminAgent::Facades::Container.logger.log('Info', "Invalidating #{id_cache} cache..")
|
|
36
43
|
end
|
|
37
44
|
|
|
45
|
+
def self.users_reload_allowed?
|
|
46
|
+
@users_reload_mutex.synchronize do
|
|
47
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
48
|
+
return false if @users_reloaded_at && now - @users_reloaded_at < USERS_RELOAD_INTERVAL_IN_SECONDS
|
|
49
|
+
|
|
50
|
+
@users_reloaded_at = now
|
|
51
|
+
true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
38
55
|
def can?(action, collection, allow_fetch: false)
|
|
39
56
|
return true unless permission_system?
|
|
40
57
|
|
|
@@ -45,6 +62,7 @@ module ForestAdminAgent
|
|
|
45
62
|
|
|
46
63
|
unless is_allowed
|
|
47
64
|
collections_data = get_collections_permissions_data(force_fetch: true)
|
|
65
|
+
user_data = get_user_data(caller.id, reload: true)
|
|
48
66
|
is_allowed = permission_allowed?(collections_data, collection, action, user_data)
|
|
49
67
|
end
|
|
50
68
|
|
|
@@ -246,7 +264,22 @@ module ForestAdminAgent
|
|
|
246
264
|
permissions[:segments][collection.name.to_sym]
|
|
247
265
|
end
|
|
248
266
|
|
|
249
|
-
def get_user_data(user_id)
|
|
267
|
+
def get_user_data(user_id, reload: false)
|
|
268
|
+
users = cached_users
|
|
269
|
+
return users[user_id.to_s] if users.key?(user_id.to_s) && !reload
|
|
270
|
+
|
|
271
|
+
reload_users[user_id.to_s]
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def get_team(rendering_id)
|
|
275
|
+
permissions = get_rendering_data(rendering_id)
|
|
276
|
+
|
|
277
|
+
permissions[:team]
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
private
|
|
281
|
+
|
|
282
|
+
def cached_users
|
|
250
283
|
cache.get_or_set('forest.users') do
|
|
251
284
|
response = fetch('/liana/v4/permissions/users')
|
|
252
285
|
users = {}
|
|
@@ -258,17 +291,16 @@ module ForestAdminAgent
|
|
|
258
291
|
ForestAdminAgent::Facades::Container.logger.log('Debug', 'Refreshing user permissions cache')
|
|
259
292
|
|
|
260
293
|
users
|
|
261
|
-
end
|
|
294
|
+
end
|
|
262
295
|
end
|
|
263
296
|
|
|
264
|
-
def
|
|
265
|
-
|
|
297
|
+
def reload_users
|
|
298
|
+
return cached_users unless self.class.users_reload_allowed?
|
|
266
299
|
|
|
267
|
-
|
|
300
|
+
self.class.invalidate_cache('forest.users')
|
|
301
|
+
cached_users
|
|
268
302
|
end
|
|
269
303
|
|
|
270
|
-
private
|
|
271
|
-
|
|
272
304
|
# An empty list of leaves resolves to no collection at all — a polymorphic relation declaring
|
|
273
305
|
# no `foreign_collections`. `[].all?` would allow it unconditionally, which is the one answer
|
|
274
306
|
# this guard must never give by default, so it counts as denied.
|
|
@@ -293,6 +325,7 @@ module ForestAdminAgent
|
|
|
293
325
|
|
|
294
326
|
@read_permissions_refetched = true
|
|
295
327
|
refetched = get_collections_permissions_data(force_fetch: true)
|
|
328
|
+
user_data = get_user_data(caller.id, reload: true)
|
|
296
329
|
|
|
297
330
|
names.to_h { |name| [name, read_allowed?(refetched, name, user_data)] }
|
|
298
331
|
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.44.
|
|
4
|
+
version: 1.44.4
|
|
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: 2026-
|
|
12
|
+
date: 2026-10-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|