Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions on users logic #39

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Permissions on users logic #39

wants to merge 3 commits into from

Conversation

tonongregory
Copy link
Collaborator

Description

Add permission to view & execute process.

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici on change la config https://symfony.com/doc/current/security.html#hierarchical-roles
On ajoute au role ROLE_SUPER_ADMIN pour chaque process un role ROLE_PROCESS_VIEW#{process.code} && ROLE_PROCESS_EXECUTE#{process.code}


return $filters->add(
LogProcessFilter::new('process', $processList, $id)
)->add(
ChoiceFilter::new('level')->setChoices(array_combine(Level::NAMES, Level::VALUES))
)->add('message')->add('context')->add('createdAt');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modification du query builder de la page de listing des logs pour ne pas afficher les rôles sur lesquels l'user connecté n'a pas le role ROLE_PROCESS_VIEW#{process.code}

@@ -153,4 +160,22 @@ private function getLogFilePath(ProcessExecution $processExecution): string
\DIRECTORY_SEPARATOR.$processExecution->logFilename
;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modification du query builder de la page de listing de l'execution des process pour ne pas afficher les rôles sur lesquels l'user connecté n'a pas le role ROLE_PROCESS_VIEW#{process.code}

@njoubert-cleverage njoubert-cleverage added enhancement New feature or request and removed enhancement New feature or request labels Feb 10, 2025
@njoubert-cleverage njoubert-cleverage added this to the v3.0 milestone Feb 21, 2025
$processRoles = array_merge(...array_map(fn ($code) => ['ROLE_PROCESS_VIEW#'.$code, 'ROLE_PROCESS_EXECUTE#'.$code], $processCodes));
$roleHierarchy = $container->getParameter('security.role_hierarchy.roles');
if (\is_array($roleHierarchy)) {
$roleHierarchy['ROLE_SUPER_ADMIN'] = array_merge($roleHierarchy['ROLE_SUPER_ADMIN'] ?? [], $processRoles);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rajouter 2 niveaux ROLE_PROCESS_VIEW et ROLE_PROCESS_EXECUTE qui contiennent leurs enfants respectifs. Du coup ROLE_SUPER_ADMIN, contient [ROLE_PROCESS_VIEW, ROLE_PROCESS_EXECUTE].

Ajouter un bout de doc expliquant qu'il suffit de mettre un role_hierarchy: ROLE_ADMIN: [ROLE_PROCESS_VIEW, ROLE_PROCESS_EXECUTE] si on a pas besoin de cette protection.

code: {
comparison: '=',
value: process.code,
{% if is_granted("ROLE_PROCESS_VIEW##{process.code}", process) %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ajouter ROLE_PROCESS_VIEW

<td>{% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %}</td>
<td>{% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %}</td>
<td class="text-right">
{% if is_granted("ROLE_PROCESS_EXECUTE##{process.code}", process) %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ajouter ROLE_PROCESS_EXECUTE

$roles = $this->roleHierarchy->getReachableRoleNames($this->getUser()?->getRoles() ?? []);
$qb = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
$qb->andWhere(
$qb->expr()->in(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si l'user a accès a ROLE_PROCESS_VIEW alors ne pas faire le filtrage.


#[IsGranted('ROLE_USER')]
#[IsGranted('ROLE_SUPER_ADMIN')]
class UserCrudController extends AbstractCrudController
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A voir si on fait une gestion des groupes via une admin ou juste via le security.yaml role_hierarchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants