MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / _default_acl

Method _default_acl

keepercommander/discovery_common/process.py:296–347  ·  view source on GitHub ↗
(self,
                     discovery_vertex: DAGVertex,
                     content: DiscoveryObject,
                     discovery_parent_vertex: DAGVertex)

Source from the content-addressed store, hash-verified

294 return content
295
296 def _default_acl(self,
297 discovery_vertex: DAGVertex,
298 content: DiscoveryObject,
299 discovery_parent_vertex: DAGVertex) -> UserAcl:
300 # Check to see if this user already belongs to another record vertex, or belongs to this one.
301 belongs_to = False
302 is_admin = False
303 is_iam_user = False
304
305 parent_content = DiscoveryObject.get_discovery_object(discovery_parent_vertex)
306
307 # User record the already exists.
308 # This means the vertex has a record UID, doesn't mean it exists in the vault.
309 # It may have been added during this processing.
310 if content.record_exists is False:
311 belongs_to = True
312
313 # Is this user the admin for the resource?
314 if parent_content.access_user is not None:
315 # If this user record's user matches the user that was used to log into the parent resource,
316 # then this user is the admin for the parent resource.
317 if parent_content.access_user.user == content.item.user:
318 is_admin = True
319
320 # User record does not exist.
321 else:
322 belongs_to_record_vertex = self.record_link.acl_has_belong_to_vertex(discovery_vertex)
323
324 # If the user doesn't belong to any other vertex, it will be long the parent resource.
325 if belongs_to_record_vertex is None:
326 self.logger.debug(" user vertex does not belong to another resource vertex")
327 belongs_to = True
328
329 else:
330 parent_record_vertex = self.record_link.get_record_uid(discovery_parent_vertex)
331 if parent_record_vertex is not None:
332 if belongs_to_record_vertex == parent_record_vertex:
333 self.logger.debug(" user vertex already belongs to the parent resource vertex")
334 belongs_to = True
335 else:
336 self.logger.debug(" user vertex does not belong to any other resource vertex")
337
338 # If the parent resource is a provider, then this user is an IAM user.
339 if parent_content.object_type_value == "providers":
340 is_iam_user = True
341
342 acl = UserAcl.default()
343 acl.belongs_to = belongs_to
344 acl.is_admin = is_admin
345 acl.is_iam_user = is_iam_user
346
347 return acl
348
349 def _directory_exists(self, domain: str, directory_info_func: Callable, context: Any) -> Optional[DirectoryResult]:
350

Callers 2

_process_levelMethod · 0.95

Calls 5

get_discovery_objectMethod · 0.80
defaultMethod · 0.80
debugMethod · 0.45
get_record_uidMethod · 0.45

Tested by

no test coverage detected