interface UserPermissionReadInterface (View source)

Read access to what a user may do: permissions, uberuser status, template grants and zone ownership.

Methods

array
getUserPermissions(int $userId)

Get all permissions for a specific user

bool
hasAdminPermission(int $userId)

Check if a user has admin permissions

bool
templateGrantsUberuser(int $permTemplId)

Check whether a permission template grants the uberuser permission

array
getTemplatePermissionNames(int $permTemplId)

Names of the permissions a permission template grants

int|null
findPermissionTemplateIdByName(string $name)

Id of the permission template with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike template.

array
getPermissionIdsByName(string $name)

Resolve every permission id carrying a given name

bool
isUberuser(int $userId)

Check if a specific user is an uberuser

int
countUberusers()

Count total number of uberusers (super admins) in the system

bool
isLastUberuser(int $userId)

Whether removing or demoting this user would leave no active uberuser.

bool
holdsUberuserThroughGroup(int $userId)

Whether a group the user belongs to grants the super admin permission, so changing the user's own template cannot take it away.

int
countUberusersAfter(UberuserChange $change)

How many active super admins would remain once $change is written. Inside an open transaction it locks the active super admin rows first, as isLastUberuser() does.

array
getAdminUserIds()

Ids of every user holding the ueberuser permission directly or through a group.

bool
userOwnsZone(int $userId, int $domainId)

Check if a user owns a zone directly or via group membership

array
getUserGroupIds(int $userId)

Ids of the groups the user is a member of

array
getUserOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly or through any group

array
getDirectlyOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly, without group grants; each zone once however many owner rows it has

array
countDirectlyOwnedZones(array $userIds)

getDirectlyOwnedZoneIds() counted for many users in one query

Details

array getUserPermissions(int $userId)

Get all permissions for a specific user

Parameters

int $userId

User ID to get permissions for

Return Value

array

Array of permission names

bool hasAdminPermission(int $userId)

Check if a user has admin permissions

Parameters

int $userId

User ID to check

Return Value

bool

True if the user is an admin

bool templateGrantsUberuser(int $permTemplId)

Check whether a permission template grants the uberuser permission

Parameters

int $permTemplId

Permission template ID

Return Value

bool

True if the template grants user_is_ueberuser

array getTemplatePermissionNames(int $permTemplId)

Names of the permissions a permission template grants

Parameters

int $permTemplId

Return Value

array

int|null findPermissionTemplateIdByName(string $name)

Id of the permission template with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike template.

Parameters

string $name

Return Value

int|null

array getPermissionIdsByName(string $name)

Resolve every permission id carrying a given name

perm_items.name has no unique constraint, so a name can map to several rows and all of them grant the permission.

Parameters

string $name

Permission name as stored in perm_items

Return Value

array

Matching permission ids, empty when the permission is absent

bool isUberuser(int $userId)

Check if a specific user is an uberuser

Parameters

int $userId

User ID to check

Return Value

bool

True if user is an uberuser

int countUberusers()

Count total number of uberusers (super admins) in the system

Return Value

int

Number of uberusers

bool isLastUberuser(int $userId)

Whether removing or demoting this user would leave no active uberuser.

Inside an open transaction it locks the active uberuser rows first, so callers that check and then write in one transaction cannot race each other.

Parameters

int $userId

Return Value

bool

bool holdsUberuserThroughGroup(int $userId)

Whether a group the user belongs to grants the super admin permission, so changing the user's own template cannot take it away.

Parameters

int $userId

Return Value

bool

int countUberusersAfter(UberuserChange $change)

How many active super admins would remain once $change is written. Inside an open transaction it locks the active super admin rows first, as isLastUberuser() does.

Parameters

UberuserChange $change

Return Value

int

array getAdminUserIds()

Ids of every user holding the ueberuser permission directly or through a group.

Return Value

array

bool userOwnsZone(int $userId, int $domainId)

Check if a user owns a zone directly or via group membership

Parameters

int $userId

User ID to check

int $domainId

Domain/zone ID

Return Value

bool

True if the user owns the zone

array getUserGroupIds(int $userId)

Ids of the groups the user is a member of

Parameters

int $userId

Return Value

array

array getUserOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly or through any group

Parameters

int $userId

Return Value

array

array getDirectlyOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly, without group grants; each zone once however many owner rows it has

Parameters

int $userId

Return Value

array

array countDirectlyOwnedZones(array $userIds)

getDirectlyOwnedZoneIds() counted for many users in one query

Parameters

array $userIds

Return Value

array

Zone count keyed by user id; every requested id is present