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

Security ViewHelper: Subgroups of Backend User Group #1719

Open
SventB opened this issue Apr 14, 2021 · 3 comments
Open

Security ViewHelper: Subgroups of Backend User Group #1719

SventB opened this issue Apr 14, 2021 · 3 comments

Comments

@SventB
Copy link

SventB commented Apr 14, 2021

In the security ViewHelper (v:security.allow or v:security.deny) the subgroups of backend user groups aren't considered.
E.g. when using this ViewHelper in Fluid...

<v:security.allow backendUserGroups="5">

...the ViewHelper should not only check if the current backend user has group with uid 5 assigned, but also, if one of his assigned backend groups has the group with uid 5 as subgroup (or one of the subgroups has this group assigned).

There is a core function to get the BE groups and subgroups of a current user:

\TYPO3\CMS\Backend\Utility\BackendUtility::getListGroupNames()
@SventB
Copy link
Author

SventB commented Apr 14, 2021

This should do it (tested in TYPO3 v8):

- $currentBackendUser = $this->getCurrentBackendUser();
- $currentUserGroups = trim($currentBackendUser['usergroup'], ',');
- $userGroups = false === empty($currentUserGroups) ? explode(',', $currentUserGroups) : [];
+ $userGroups = array_keys(\TYPO3\CMS\Backend\Utility\BackendUtility::getListGroupNames());

@neufeind
Copy link
Contributor

neufeind commented Apr 6, 2022

That one was deprecated in v9: https://docs.typo3.org/c/typo3/cms-core/9.5/en-us/Changelog/9.0/Deprecation-81534-BackendUtilitygetListGroupNamesDeprecated.html
Use getGroupNames() instead now.

But looking at the code imho that also doesn't take subgroups into account?

@SventB
Copy link
Author

SventB commented Apr 25, 2022

No, don't use getGroupNames() because it returns all existing BE usergroups.
This is the fix for TYPO3 v10:

- $currentUserGroups = trim($currentBackendUser['usergroup'], ',');
+ $currentUserGroups = trim($currentBackendUser['usergroup_cached_list'], ',');

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

No branches or pull requests

2 participants