mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 03:38:47 +02:00
Added permissions to control access to info providers and oauth tokens
This commit is contained in:
parent
7bbf612394
commit
b3b205cd6e
9 changed files with 72 additions and 1 deletions
|
@ -105,6 +105,9 @@ class PermissionPresetsHelper
|
|||
$this->permissionResolver->setAllOperationsOfPermission($perm_holder, 'suppliers', PermissionData::ALLOW);
|
||||
$this->permissionResolver->setAllOperationsOfPermission($perm_holder, 'projects', PermissionData::ALLOW);
|
||||
|
||||
//Allow to manage Oauth tokens
|
||||
$this->permissionResolver->setPermission($perm_holder, 'system', 'manage_oauth_tokens', PermissionData::ALLOW);
|
||||
|
||||
}
|
||||
|
||||
private function editor(HasPermissionsInterface $permHolder): HasPermissionsInterface
|
||||
|
@ -139,6 +142,9 @@ class PermissionPresetsHelper
|
|||
//Various other permissions
|
||||
$this->permissionResolver->setPermission($permHolder, 'tools', 'lastActivity', PermissionData::ALLOW);
|
||||
|
||||
//Allow to create parts from information providers
|
||||
$this->permissionResolver->setPermission($permHolder, 'info_providers', 'create_parts', PermissionData::ALLOW);
|
||||
|
||||
|
||||
return $permHolder;
|
||||
}
|
||||
|
|
|
@ -138,4 +138,13 @@ class PermissionSchemaUpdater
|
|||
$holder->getPermissions()->removePermission('devices');
|
||||
}
|
||||
}
|
||||
|
||||
private function upgradeSchemaToVersion3(HasPermissionsInterface $holder): void //@phpstan-ignore-line This is called via reflection
|
||||
{
|
||||
//If the info_providers permissions are not defined yet, set it if the user can create parts
|
||||
if (!$holder->getPermissions()->isAnyOperationOfPermissionSet('info_providers')) {
|
||||
$user_can_create_parts = $holder->getPermissions()->getPermissionValue('parts', 'create');
|
||||
$holder->getPermissions()->setPermissionValue('info_providers', 'create_parts', $user_can_create_parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue