Principal

final readonly class \TYPO3\CMS\Core\Authentication\Principal

Immutable representation of an authenticated user: who the user is, in which realm the user authenticated - independent of how and where the underlying identity is stored.

The PrincipalContext carries role, id, groups and impersonation, the data the permission evaluation works with. The principal adds what only authentication knows. The role in the context is the only source of the authorization level.

Frontend principals always carry the role USER. Their context holds an fe_users uid and fe_groups uids, so it must never be handed to a permission evaluation of backend users.

The group ids are the resolved user groups including their subgroups, as the user aspect and the permission context expect them, not only the groups the user is a direct member of. The group names belong to the same groups.

The read surface voters decide on is public API: the role, id and group ids of the context and isBackendUser(). Everything else, e.g. creating a principal, is not part of TYPO3 Core API yet: the identity of a principal is still bound to a local user record, see the uid in the context.

Table of Contents

Properties

$context  : PrincipalContext
$groupNames  : array
$realmIdentifier  : string
$username  : string

Methods

__construct()  : mixed
belongsToFrontendRealm()  : bool
isBackendUser()  : bool
Whether the principal denotes a backend user. Every realm other than the frontend realm authenticates backend users, the backend realm as well as realms of token based channels.

Properties

$realmIdentifier

public string $realmIdentifier

Methods

__construct()

public __construct(PrincipalContext $context, string $realmIdentifier, string $username[, array<int, string> $groupNames = [] ]) : mixed

Parameters

$context : PrincipalContext
$realmIdentifier : string
$username : string
$groupNames : array<int, string> = []

belongsToFrontendRealm()

public belongsToFrontendRealm() : bool

Return values

bool

isBackendUser()

Whether the principal denotes a backend user. Every realm other than the frontend realm authenticates backend users, the backend realm as well as realms of token based channels.

public isBackendUser() : bool

Return values

bool
On this page