Project

General

Profile

Actions

Bug #106367

open

Pages with "show at any login" are not accessible to users without any assigned group

Added by Alexander Schnitzler 3 days ago. Updated 3 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Authentication
Target version:
-
Start date:
2025-03-13
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I stumbled upon the following scenario:

I have a page which is restricted to logged in users. The virtual group "show at any login" has the id -2. My expectation is that users with a login (active, valid session) should be able to access that page.

That user however, does not have any group assigned.

When \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication::createUserAspect() assembles all groups of a user, it only assigns -2 if the user already has at least one group assigned.

$userGroups = [0];
$isUserAndGroupSet = is_array($this->user) && !empty($this->userGroups);
if ($isUserAndGroupSet) {
    // group -2 is not an existing group, but denotes a 'default' group when a user IS logged in.
    // This is used to let elements be shown for all logged in users!
    $userGroups[] = -2;
    $groupsFromUserRecord = array_keys($this->userGroups);
} else {
    // group -1 is not an existing group, but denotes a 'default' group when not logged in.
    // This is used to let elements be hidden, when a user is logged in!
    $userGroups[] = -1;
    if ($respectUserGroups) {
        // For cases where logins are not banned from a branch usergroups can be set based on IP masks so we should add the usergroups uids.
        $groupsFromUserRecord = array_keys($this->userGroups);
    } else {
        // Set to blank since we will NOT risk any groups being set when no logins are allowed!
        $groupsFromUserRecord = [];
    }
}

So I think this is a bug, actually. Users without a user group, that are logged in, should be given the -2 group.

Actions #1

Updated by Garvin Hicking 3 days ago ยท Edited

Some references, did not dig further (yet)

https://review.typo3.org/c/Packages/TYPO3.CMS/+/66066 didn't change this ported behaviour. However in https://review.typo3.org/c/Packages/TYPO3.CMS/+/57104 this looks as if the else part was not properly ported
With that earlier code, in case of missing usergroups a group -1 was always added if I read that right.

Specifically: https://review.typo3.org/c/Packages/TYPO3.CMS/+/57104/21/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php#947

Update : Ah, never mind, I misread parts of the 'else', so that was left unchanged.

Actions

Also available in: Atom PDF