Skip to content

RbacSecurityUser

RbacUser will handle roles and permissions for users

class RbacSecurityUser extends SecurityUser

ExtendsSecurityUser
Since1.0.0
SourceUser/RbacSecurityUser.php
ConstantValueDescription
ROLES_NAMESPACE'org.quiote.user.RbacSecurityUser.roles'The namespace under which roles will be stored.
MethodDescription
getRoles(): array<int, string>Return a list of roles this user has been granted.
grantRole(string $role): voidSet a role membership for this user.
grantRoles(array<int, string> $roles): voidSet many role memberships for this user.
hasRole(string $role): boolCheck whether or not a user is a member of a certain role.
initialize(Context $context, array<string, mixed> $parameters = []): voidInitialize this User.
reset(): voidClears the role state on top of the parent reset.
revokeAllRoles(): voidRevoke all roles.
revokeRole(string $role): voidRevoke a role membership for this user.
shutdown(): voidExecute the shutdown procedure.

public function getRoles(): array<int, string>

Return a list of roles this user has been granted.

Returns array``<``int``, ``string``> — An array of role names.

public function grantRole(string $role): void

Set a role membership for this user.

The role name to add to this user.

ParameterTypeDescription
$rolestringThe role name to add to this user.

public function grantRoles(array<int, string> $roles): void

Set many role memberships for this user.

An array of role names.

ParameterTypeDescription
$rolesarray``<``int``, ``string``>An array of role names.

public function hasRole(string $role): bool

Check whether or not a user is a member of a certain role.

The role name to remove from this user.

ParameterTypeDescription
$rolestringThe role name to remove from this user.

Returns bool — Whether or not the user is a member of the given role.

public function initialize(Context $context, array<string, mixed> $parameters = []): void

Initialize this User.

An associative array of initialization parameters.

ParameterTypeDescription
$contextContextAn Context instance.
$parametersarray``<``string``, ``mixed``>An associative array of initialization parameters.
ThrowsWhen
InitializationExceptionIf an error occurs while initializing this User.

public function reset(): void

Clears the role state on top of the parent reset.

Drops the granted roles and the cached role definitions along with the context, parameters and attributes, then delegates to the parent so the authentication and credential state goes too. Nothing is persisted — roles held only in memory are discarded.

public function revokeAllRoles(): void

Revoke all roles.

public function revokeRole(string $role): void

Revoke a role membership for this user.

The role name to remove from this user.

ParameterTypeDescription
$rolestringThe role name to remove from this user.

public function shutdown(): void

Execute the shutdown procedure.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
addCredential()SecurityUserAdd a credential to this user.
appendAttribute()UserAppends a value to an array attribute and marks the user dirty.
appendAttributeByRef()UserAppends a value by reference to an array attribute and marks the user dirty.
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearAttributes()UserRemoves every attribute in every namespace and marks the user dirty.
clearCredentials()SecurityUserClear all credentials associated with this user.
clearParameters()ParameterHolderClear all parameters associated with this request.
getAttribute()AttributeHolderRetrieve an attribute.
getAttributeNames()AttributeHolderRetrieve an array of attribute names.
getAttributeNamespace()AttributeHolderRetrieve all attributes within a namespace.
getAttributeNamespaces()AttributeHolderRetrieve an array of attribute namespaces.
getAttributes()AttributeHolderRetrieve all attributes within a namespace.
getContext()UserRetrieve the current application context.
getCredentials()SecurityUserReturns the list of credentials that this user possesses.
getDefaultNamespace()AttributeHolderGet the default namespace name
getFlatAttributeNames()AttributeHolderRetrieve an array of flattened attribute names.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
getStorageNamespace()UserRetrieve the Storage namespace
getTokenClaims()SecurityUserThe validated claims this identity was resolved from, when RbacSecurityUser::isTokenDerived() is true.
hasAttribute()AttributeHolderIndicates whether or not an attribute exists.
hasAttributeNamespace()AttributeHolderIndicates whether or not an attribute namespace exists.
hasCredential()SecurityUserIndicates whether or not this user has a credential.
hasCredentials()SecurityUserIndicates whether or not this user has a credential or a set of credentials.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
isAuthenticated()SecurityUserIndicates whether or not this user is authenticated.
isDirty()UserWhether this request changed user state that still needs persisting.
isTokenDerived()SecurityUserTrue when this user’s identity was (re-)established from a token rather than the session, per $tokenDerived.
markClean()UserRecord that in-memory state now matches what is persisted.
markDirty()UserForce this user to be persisted at the request boundary.
markTokenDerived()SecurityUserMark (or clear) this user as token-derived, for this request only — the marker is not persisted (see $tokenDerived).
persistAttributesImmediate()UserImmediately persist current user attributes (or a filtered subset) to storage.
removeAttribute()UserRemoves a single attribute and marks the user dirty so the removal is persisted.
removeAttributeNamespace()UserRemoves a whole attribute namespace and marks the user dirty.
removeCredential()SecurityUserRemove a credential from this user.
removeParameter()ParameterHolderRemove a parameter.
restoreContext()UserRe-bind context after unserialization without re-running full initialize logic.
restoreIdentityFromStorage()SecurityUserRe-populate this user’s core identity attributes (see CORE_IDENTITY_KEYS) from storage.
setAttribute()UserSets an attribute and marks the user dirty so shutdown() persists it.
setAttributeByRef()UserSets an attribute by reference and marks the user dirty.
setAttributes()UserMerges a set of attributes into a namespace and marks the user dirty.
setAttributesByRef()UserMerges a set of attributes by reference into a namespace and marks the user dirty.
setAuthenticated()SecurityUserSet the authenticated status of this user.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.
setTokenClaims()SecurityUserSet (or clear) the validated claims this identity was resolved from.
startup()UserStartup the user.