Review main Merged

83087[FEATURE] Allow creating backend user group presets

Marcin Sągol CR +2 V +2 Hard +746 −7 updated 03/13/24, 08:46

Commit message

When installing TYPO3, the final step (5) has
been updated to include an additional checkbox.
This checkbox will allow the user to decide if
they want to have 2 default backend groups,
Editor and Advanced Editor, installed.

These groups will be created with predefined
permission presets defined through YAML files
in `EXT:install/Configuration/PermissionPreset/`:

- be_groups_editor.yaml
- be_groups_advanced_editor.yaml

In these files, access is defined to to modules,
dashboard widgets, table listings and editing,
allowed exclude fields, etc.

A new dedicated CLI command is also introduced
to create these groups later if they were skipped
during the TYPO3 installation process.

The command can be executed by calling:

  ./bin/typo3 setup:begroups:default

It supports both interactive and non-interactive
modes and allows the creation of both groups or
only one selected group.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 11

Review log 5980

Show 3955 earlier messages
  1. Marcin Sągol uploaded patch set 1 02/23/24, 11:21

  2. core-ci voted on patch set 1 V -1 02/23/24, 11:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53477

  3. Andreas Kienast commented on patch set 1 CR -1 02/23/24, 11:42

    InstallerController.php:644

    Please wrap this in parentheses, the null coalesce binding is weaker than the comparison. The code will basically evaluate as `$request->getParsedBody()['install']['values']['backendgroups'] ?? ('' === 'creategroups')` See example: ```bash php > $foo = 'x'; php > var_dump($foo ?? '' === 'x'); string(1) "x" php > var_dump(($foo ?? '') === 'x'); bool(true) php > var_dump($foo ?? ('' === 'x')); string(1) "x" ```

    be_groups_advanced_editor.yaml:1

    by

    be_groups_editor.yaml:1

    by

    ShowDefaultConfiguration.html:47

    Do you want pre-configured backend groups?

    ShowDefaultConfiguration.html:49

    backend groups
  4. Marcin Sągol uploaded patch set 2 CR -1 V -1 02/23/24, 11:48

  5. Marcin Sągol uploaded patch set 3 02/23/24, 11:50

  6. core-ci voted on patch set 2 V +1 02/23/24, 11:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53480

  7. core-ci voted on patch set 3 V +1 02/23/24, 11:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53481

  8. Marcin Sągol commented on patch set 3 02/23/24, 12:00

    InstallerController.php:644 Reply

    Done

    be_groups_advanced_editor.yaml:1 Reply

    Done

    be_groups_editor.yaml:1 Reply

    Done

    ShowDefaultConfiguration.html:47 Reply

    Done

    ShowDefaultConfiguration.html:49 Reply

    Done
  9. Marcin Sągol uploaded patch set 4 V +1 02/23/24, 13:00

  10. core-ci voted on patch set 4 V +1 02/23/24, 13:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53490

  11. Oliver Klee updated the commit message in patch set 5 V +1 02/23/24, 14:48

  12. core-ci voted on patch set 5 V +1 02/23/24, 14:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53507

  13. Oli Bartsch commented on patch set 5 CR -1 02/23/24, 21:13

    Missing feature ReST.

    SetupBackendGroupsCommand.php:18

    I suggest having this command in ext:backend

    SetupBackendGroupsCommand.php:51

    Seems like `addOption()` does not feature a sixth parameter.

    SetupBackendGroupsCommand.php:72

    We should persist this with `$input->setInteractive()`.

    SetupBackendGroupsCommand.php:98

    I suggest using `SymfonyStyle` instead.

    ServiceProvider.php:448

    I suggest using backend:usergroup:create similar to the existing backend:user:create command.
  14. Marcin Sągol commented on patch set 5 02/26/24, 09:55

    SetupBackendGroupsCommand.php:51 Reply

    Well i does: array|Closure $suggestedValues – The values used for input completion
  15. Marcin Sągol uploaded patch set 6 CR -1 V +1 02/26/24, 11:17

  16. Marcin Sągol updated the commit message in patch set 7 02/26/24, 11:18

  17. Marcin Sągol commented on patch set 7 02/26/24, 11:19

    SetupBackendGroupsCommand.php:18 Reply

    Done

    SetupBackendGroupsCommand.php:72 Reply

    Done

    SetupBackendGroupsCommand.php:98 Reply

    Done

    ServiceProvider.php:448 Reply

    Done
  18. Marcin Sągol commented on patch set 7 02/26/24, 11:19

    SetupBackendGroupsCommand.php:18 Reply

    Done

    SetupBackendGroupsCommand.php:72 Reply

    Done
  19. core-ci voted on patch set 6 V -1 02/26/24, 11:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53598

  20. core-ci voted on patch set 7 V -1 02/26/24, 11:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53599

  21. Marcin Sągol uploaded patch set 8 V -1 02/26/24, 12:47

  22. core-ci voted on patch set 8 V +1 02/26/24, 12:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53613

  23. Garvin Hicking commented on patch set 8 02/28/24, 08:37

    Some thoughts and documentation ideas. We should really decide on one consistent term. Generally: I like this concept of presets a lot and see much potential here, thanks so much for working on it!

    CreateBackendUserGroupCommand.php:67

    In the other instances you use the term "backend Role groups" and sometimes "backend user groups", could you unify this to only consistently use one term? Probably we should call it either "backend roles" or "backend user groups"? (Also, "Role" is not really a very specific term here and IMO doesn't rectify uppercasing?)

    CreateBackendUserGroupCommand.php:68

    The "None" option exists here, but not in the list above? Maybe for the future we could use an enum or object constant to reference the list of allowed values here?

    Services.yaml:20

    use "group" singular here

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:40

    Maybe use "Advanced Editor" here with quotes for better readability?

    SetupService.php:221

    Just an idea: Currently this "supermethod" only operates on two fixed presets. I wonder if in the future this may be expanded, and it's worth at this point already to create a more specific pattern for usergroup creation? Something like a DTO/service/factory. At this point it might be overkill, but I'm afraid that we'll get new presets here and then these blocks get copy and pasted...?

    SetupService.php:226

    I wonder if we should prefer to use the DataHandler here, for forward-compatibility when TCA changes occur and more fields may be populated, and also have a history entry about the creation of these records?

    ShowDefaultConfiguration.html:47

    "Do you want to setup pre-configured user groups?" (or whatever the term for "backend user role group" will be used ;)

    ShowDefaultConfiguration.html:49

    I wonder if this should also offer the ability to either create Editor AND advanced editor or either. Would a dropdown/multiple checkboxes here be more consistent with the CLI option that allows more flexibility?
  24. Marcin Sągol commented on patch set 8 02/29/24, 10:47

    Services.yaml:20 Reply

    Would it be a good idea if the command allows to create 2 by default?

    SetupService.php:221 Reply

    I was considering DTO etc. but not now. The core team members plan to introduce presets for various data types and after they are introduced and merged into TYPO3 core, this code can be updated. For now i wanted it to be as simple and small as possible, to make it easier to change it in the future.

    ShowDefaultConfiguration.html:49 Reply

    Benni suggested only checkbox. I think that is fone for now.
  25. Garvin Hicking commented on patch set 8 02/29/24, 11:03

    Services.yaml:20 Reply

    Then the beginning of the sentence needs to remove "a" because that currently refers to the singular. both ways are fine by me :)
  26. Marcin Sągol commented on patch set 8 02/29/24, 11:57

    CreateBackendUserGroupCommand.php:67 Reply

    I will follow the `backend user group` naming, as suggested.

    CreateBackendUserGroupCommand.php:68 Reply

    The None is only too easily cancel the command execution in the interactive mode.

    Services.yaml:20 Reply

    Done
  27. Marcin Sągol uploaded patch set 9 V +1 02/29/24, 12:03

  28. Marcin Sągol uploaded patch set 10 02/29/24, 12:06

  29. Marcin Sągol uploaded patch set 11 02/29/24, 12:07

  30. core-ci voted on patch set 9 V -1 02/29/24, 12:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53717

  31. Marcin Sągol commented on patch set 9 02/29/24, 12:10

    CreateBackendUserGroupCommand.php:67 Reply

    Done

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:40 Reply

    Done

    SetupBackendGroupsCommand.php:51 Reply

    Done

    SetupService.php:226 Reply

    This code is part of the Install package atm. so I am not sure if we should use DH here. Other core devs feedback is welcomed.

    ShowDefaultConfiguration.html:47 Reply

    Done
  32. core-ci voted on patch set 10 V -1 02/29/24, 12:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53718

  33. core-ci voted on patch set 11 V -1 02/29/24, 12:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53719

  34. Marcin Sągol uploaded patch set 12 V -1 02/29/24, 12:18

  35. core-ci voted on patch set 12 V +1 02/29/24, 12:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53720

  36. Garvin Hicking commented on patch set 12 CR -1 02/29/24, 15:07

    On it, there's an issue with the no-interaction and I'd really like to get some more structure into the usergroup defaults/string, will make a proposal
  37. Garvin Hicking uploaded patch set 13 CR -1 V +1 02/29/24, 15:51

    Suggestion for Enum and some unification ideas
  38. core-ci voted on patch set 13 V -1 02/29/24, 15:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53729

  39. Garvin Hicking commented on patch set 13 CR +1 V +1 02/29/24, 15:58

    Works for me; the open issues are open to feedback from others of course.

    CreateBackendUserGroupCommand.php:68 Reply

    I took the liberty to upload a patch set that uses a ENUM to enforce a more streamlined usage of the preset names and their retrieval. Feel free to revert if you don't like it. I changed the interactive mode a bit to be not required when you use the "--groups" or "-g" command. As soon as that is set, it doesn't ask. IMO this makes the conditions for checking the option a bit clearer.

    SetupService.php:40

    I'm not sure at this place if the change to "readonly" could have side effects. Class is marked "internal" so it wouldn't be a BC at least! 😊

    SetupService.php:221 Reply

    I understand. I added a note at the place for a future refactoring to easy my mind.

    SetupService.php:226 Reply

    Probably the installer doesn't have a working DH instance at this point, making it more complex. I think we're good with this then.

    ShowDefaultConfiguration.html:49 Reply

    Ah, I did not know about this. I added a note here to indicate that people can rename their presets, and used the "backend user group" name here.
  40. Garvin Hicking uploaded patch set 14 CR +1 V +1 02/29/24, 16:00

    CGL
  41. Garvin Hicking uploaded patch set 15 02/29/24, 16:02

    Fix ENUM class comment
  42. core-ci voted on patch set 14 V +1 02/29/24, 16:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53731

  43. core-ci voted on patch set 15 V +1 02/29/24, 16:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53732

  44. Garvin Hicking commented on patch set 15 CR +1 V +1 03/01/24, 13:43

    (I can live without the ENUM or other abstraction; if that overcomplicates things, I just had to get this redundancy off my chest *g*)
  45. Guido Schmechel commented on patch set 15 03/02/24, 12:44

    CreateBackendUserGroupCommand.php:88

    3rd parameter neccessary?

    SetupService.php:263

    Maybe it's just my taste, but isn't the readability quite complex? Could it be simplified with a loop and an array? What are the other opinions?
  46. Nikita Hovratov commented on patch set 15 03/03/24, 19:00

    be_groups_editor.yaml:1

    to be
  47. Christian Kuhn commented on patch set 15 03/04/24, 07:32

    SetupService.php:40 Reply

    readonly is ok: classes that have no properties apart from DI stuff (which should be readonly), can be marked readonly without headaches.
  48. Marcin Sągol commented on patch set 15 03/04/24, 14:36

    SetupService.php:263 Reply

    @guido.schmechel@brandung.de I would keep it as it is for now. In the future, when the concept of presets for various record types is implemented, this may change, and perhaps some DTOs will be used. I don't want to complicate things at the moment, as it would necessitate more changes in the future when adapting to presets introduced in the core.
  49. Marcin Sągol uploaded patch set 16 CR +1 V +1 03/04/24, 14:43

  50. Marcin Sągol commented on patch set 16 03/04/24, 14:43

    CreateBackendUserGroupCommand.php:88 Reply

    Done

    be_groups_editor.yaml:1 Reply

    Done
  51. core-ci voted on patch set 16 V +1 03/04/24, 14:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53861

  52. Garvin Hicking commented on patch set 16 CR +1 V +1 03/04/24, 16:30

    SetupService.php:40 Reply

    Acknowledged
  53. Marcin Sągol commented on patch set 16 03/05/24, 13:55

    CreateBackendUserGroupCommand.php:68 Reply

    Done

    SetupService.php:263 Reply

    Done
  54. Stefan Bürk commented on patch set 16 CR -1 03/08/24, 16:10

    on it ...

    BackendUserGroupType.php:23

    We should mark this enum as internal. It make sense to refactor this to registry instead, so let's keep that door open for TYPO3 v13.

    BackendUserGroupType.php:31

    ``` @return string[] ```

    BackendUserGroupType.php:44

    ``` @return array<non-empty-string, non-empty-string> ```

    CreateBackendUserGroupCommand.php:68 Reply

    I make the enum internal. The enum move was not really required here, and a proper registry more suitable in the longterm. With the internal mark we can adjust this later on to put multiple pieces of the big picture together.

    CreateBackendUserGroupCommand.php:107

    I'm not really happy with this try-catch block. This removes the ability to display the error/exception stacktrace with `-vvv`. I would remove this try-catch here.

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:14

    ``` :bash:`...` ```

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:22

    ``` :bash:`...` ```

    be_groups_advanced_editor.yaml:178

    Editor should not see the user forgot hash (or edit it)
  55. Stefan Bürk uploaded patch set 17 CR +1 V +1 03/08/24, 16:41

  1. core-ci voted on patch set 17 V +1 03/08/24, 16:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54287

  2. Stefan Bürk commented on patch set 17 03/08/24, 16:47

    SetupService.php:46

    tailing comma ...
  3. Stefan Bürk commented on patch set 17 V +1 03/08/24, 16:48

    BackendUserGroupType.php:23 Reply

    Done

    BackendUserGroupType.php:31 Reply

    Done

    BackendUserGroupType.php:44 Reply

    Done

    CreateBackendUserGroupCommand.php:107 Reply

    Done

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:14 Reply

    Done

    Feature-103187-AddCliCreateBeUserGroupCommand.rst:22 Reply

    Done

    SetupService.php:46 Reply

    Done

    be_groups_advanced_editor.yaml:178 Reply

    Done
  4. Stefan Bürk updated the commit message in patch set 18 V +1 03/08/24, 16:54

  5. core-ci voted on patch set 18 V +1 03/08/24, 17:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54291

  6. Stefan Bürk voted on patch set 18 CR +1 V +1 03/08/24, 17:28

  7. Stefan Bürk commented on patch set 18 03/08/24, 17:29

    @marcin@soee.pl thanks for this patch and also taking care about removing into `EXT:backend`
  8. Benni Mack updated the commit message in patch set 19 CR +1 V +1 03/08/24, 17:43

  9. core-ci voted on patch set 19 V +1 03/08/24, 17:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54294

  10. Benni Mack commented on patch set 19 CR -1 03/08/24, 19:43

    CreateBackendUserGroupCommand.php:26

    This does not work. We now have a new dependency from EXT:backend -> EXT:install, even though EXT:install is optional. Even though requested differently before, this Command MUST go into EXT:install. I also think we should name this one differently. It is a CLI Command that creates be groups from a defined list of presets, which are hard-coded. "setup:begroups:default"
  11. Marcin Sągol uploaded patch set 20 CR -1 V +1 03/12/24, 08:43

  12. Marcin Sągol commented on patch set 20 03/12/24, 08:44

    CreateBackendUserGroupCommand.php:26 Reply

    I have moved the command to ext:install again. I have left the Enum class in the ext:backend though - this one might be used in the future when we introduce a more advanced commands for backend user creation for existing presets.
  13. core-ci voted on patch set 20 V +1 03/12/24, 08:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54401

  14. Stefan Bürk commented on patch set 20 CR -1 03/12/24, 09:05

    on it ...
  15. Stefan Bürk commented on patch set 20 03/12/24, 11:38

    CreateBackendUserGroupCommand.php:26 Reply

    The enum should be moved to. We want to avoid cross dependencies in this case. For now. I removed the todo comment from the enum. A additionally enhanced version for runtime usage in the `EXT:backend` should not use a enum, and implement something like a preset registry so agencies can provide/register custom presets as shared package (agengy package) or through the local site package. That's unrelated to this implementation. Also, it should not use the setupservice than. We have to look into it and move some parts from `EXT:install` to `EXT:core` or suitable places anyway - but that's out of scope for this patch. Due to the shared nature with the GUI based installer, and the failsafe nature of `EXT:install` this cannot be extensible and needs to be available earlie with a hard set preset. The later/additional configurable and extensible implementation is another approach, which should not used in the `EXT:install` then - so we need this separated and similar but different context solution. Therefore, moved back to `EXT:install` as a self containt implementation with a command name which leaves the command name open for a enhanved implementation. Sorry for the ping-pong on here, but it took some brain tennis to decide these things. However, thanks for providing this change and taking care in between for the changes - albeit giving a taste of playing, which was not intended. I will take care of the additional changes and push them shortly, currently still playing aroung with the patch (testing).
  16. Stefan Bürk uploaded patch set 21 CR -1 V +1 03/12/24, 11:52

  17. Guido Schmechel wrote 03/12/24, 11:54

    Removed cc Guido Schmechel.
  18. Stefan Bürk commented on patch set 21 CR -1 03/12/24, 11:56

    CreateBackendUserGroupCommand.php:26 Reply

    Done

    SetupDefaultBackendUserGroupsCommand.php:101

    The command can be executed at a later point. In the current implementation, the setup service will simply add new user groups with the permissions - on every execution. That means, that if executed 10x with `both` you will end up with ten "Editor" groups and ten "Advanced Editor" groups. Therefore, again a temp -1 - will think about it how to deal with it and add the solution then. Commented so maybe someone can ping opinion on this in the meanwhile).
  19. core-ci voted on patch set 21 V +1 03/12/24, 12:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54420

  20. Marcin Sągol commented on patch set 21 03/12/24, 12:04

    CreateBackendUserGroupCommand.php:26 Reply

    Thank you @stefan@buerk.tech. The idea from the beginning was to make it as simple as possible for now, keeping in mind that there are plans to introduce more general presets for various record types in the TYPO3 core. Then there could be a registry and all the other stuff to make it extensible etc. In the future the registry could be stored in the `ext:core` or `ext:backend` and used by `ext:install` i think as it would be one direction dependency from `ext:install` only. Probably the installer GUI should allow only the default presets to be used/handled, while the command (either the one introduced in this patch or a separate one) should handle all the presets from the not yet existing registry in the future. So for example user could enter the desired group name and apply 1..n selected presets through CLI. But this is not the scope of this task/patch :)
  21. Marcin Sągol commented on patch set 21 03/12/24, 12:10

    SetupDefaultBackendUserGroupsCommand.php:101 Reply

    It should add new groups only if the dedicated checkbox was chcked on the last installation step. Yes we can end up with multiple groups with the same name but still this would be probably a developer decision. Such groups can be renamed easily from the backend module. If we would like to handle this case more user friendly, there could be check if any of those groups exits (by name) and if yes, as user if he wants to create them any way or name set custom name for new groups.
  22. Stefan Bürk commented on patch set 21 CR +1 V +1 03/12/24, 13:14

    CreateBackendUserGroupCommand.php:26 Reply

    We will see and postpone this. But for now the clear encapsulation in the optional `ext:install`. The goal is to get this now in a first version in while avoiding to much cross-spreading for the start.

    SetupDefaultBackendUserGroupsCommand.php:101 Reply

    The point is the `cli command` and not the UI installer. Thought about it, and also talked with Benni. We start with the current state - so if the command is executed again, the groups are added again. Without duplicate checks etc. and see where the journey goes. No need to delay this further.
  23. Garvin Hicking commented on patch set 21 CR +1 V +1 03/12/24, 13:39

    The "duplicate calls" are a valid point, but I'd argue also expected behavior if run multiple times. I'd also say to merge as-is and enhance this later when "custom" presets come into it. Then it'll be easier to query a registry.
  24. Stefan Bürk voted on patch set 21 CR +2 V +2 03/13/24, 08:46

  25. Stefan Bürk merged patch set 22 03/13/24, 08:46