Service for ComponentPermissions. Provides functions to create, update and delete

Parameters

repository

the associated repository used for CRUD functionality

componentRepository

used to get Components by id

Constructors

Link copied to clipboard
constructor(repository: ComponentPermissionRepository, componentRepository: ComponentRepository)

Properties

Link copied to clipboard
@Autowired
lateinit var authorizationChecker: AuthorizationChecker

Injected, used for the checkPermission function

Link copied to clipboard
Link copied to clipboard

Injected, used to get a user based on a GropiusAuthorizationContext

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun checkIsAdmin(authorizationContext: GropiusAuthorizationContext, errorMessage: String)

Checks if the user defined by authorizationContext is a global admin

Link copied to clipboard
suspend fun checkPermission(node: Node, permission: Permission, errorMessage: String)

Checks if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard

Creates a new ComponentPermission based on the provided input Checks the authorization status

Link copied to clipboard

Updates node based on input Should be called after the node was constructed

Link copied to clipboard
suspend fun createDefaultPermission(user: GropiusUser, component: Component)

Creates the default ComponentPermission The created permission grants ADMIN and READ only to the provided user Does not check permissions or save the created permission / component

Creates the default permission on node creation The created permission grants ADMIN and READ only to the provided user Does not check permissions or save the created permission

Link copied to clipboard
protected suspend fun createNodePermission(authorizationContext: GropiusAuthorizationContext, input: CreateNodePermissionInput, nodesWithPermission: Collection<Component>, constructor: (String, String, MutableList<String>, Boolean) -> ComponentPermission): ComponentPermission

Creates a subtype of NodePermission Checks the authorization status

Link copied to clipboard
suspend fun deleteNodePermission(authorizationContext: GropiusAuthorizationContext, input: DeleteNodeInput)

Deletes a NodePermission by id Checks the authorization status

Link copied to clipboard
private suspend fun ensureAdminPermissionExistsForNode(node: V, cache: NodeCache)

Ensures that at least one permission on node grants NodePermission.ADMIN to at least one user

Link copied to clipboard
suspend fun evaluatePermission(node: Node, permission: Permission): Boolean

Evaluates if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard
suspend fun getUser(authorizationContext: GropiusAuthorizationContext): GropiusUser

Gets a GropiusUser based on the userId from the authorizationContext

Link copied to clipboard

Updates node based on input Updates name, description, entries, allUsers and users

Link copied to clipboard

Updates node based on input Updates name and description

Link copied to clipboard

Updates a NodePermission based on the provided input Checks the authorization status

Link copied to clipboard
suspend fun updatePermissionsOfNode(node: Component, addedPermissions: OptionalInput<List<ID>>, removedPermissions: OptionalInput<List<ID>>, authorizationContext: GropiusAuthorizationContext)

Adds/Removes permissions to/from a NodeWithPermissions Checks permissions on addedPermissions, but not on node Checks that at least one user has still NodePermission.ADMIN on node