RbacSecurityUser
RbacUser will handle roles and permissions for users
Synopsis
Section titled “Synopsis”class RbacSecurityUser extends SecurityUser
| Extends | SecurityUser |
| Since | 1.0.0 |
| Source | User/RbacSecurityUser.php |
Constants
Section titled “Constants”| Constant | Value | Description |
|---|---|---|
ROLES_NAMESPACE | 'org.quiote.user.RbacSecurityUser.roles' | The namespace under which roles will be stored. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getRoles(): array<int, string> | Return a list of roles this user has been granted. |
grantRole(string $role): void | Set a role membership for this user. |
grantRoles(array<int, string> $roles): void | Set many role memberships for this user. |
hasRole(string $role): bool | Check whether or not a user is a member of a certain role. |
initialize(Context $context, array<string, mixed> $parameters = []): void | Initialize this User. |
reset(): void | Clears the role state on top of the parent reset. |
revokeAllRoles(): void | Revoke all roles. |
revokeRole(string $role): void | Revoke a role membership for this user. |
shutdown(): void | Execute the shutdown procedure. |
getRoles()
Section titled “getRoles()”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.
grantRole()
Section titled “grantRole()”public function grantRole(string $role): void
Set a role membership for this user.
The role name to add to this user.
| Parameter | Type | Description |
|---|---|---|
$role | string | The role name to add to this user. |
grantRoles()
Section titled “grantRoles()”public function grantRoles(array<int, string> $roles): void
Set many role memberships for this user.
An array of role names.
| Parameter | Type | Description |
|---|---|---|
$roles | array``<``int``, ``string``> | An array of role names. |
hasRole()
Section titled “hasRole()”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.
| Parameter | Type | Description |
|---|---|---|
$role | string | The role name to remove from this user. |
Returns bool — Whether or not the user is a member of the given role.
initialize()
Section titled “initialize()”public function initialize(Context $context, array<string, mixed> $parameters = []): void
Initialize this User.
An associative array of initialization parameters.
| Parameter | Type | Description |
|---|---|---|
$context | Context | An Context instance. |
$parameters | array``<``string``, ``mixed``> | An associative array of initialization parameters. |
| Throws | When |
|---|---|
InitializationException | If an error occurs while initializing this User. |
reset()
Section titled “reset()”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.
revokeAllRoles()
Section titled “revokeAllRoles()”public function revokeAllRoles(): void
Revoke all roles.
revokeRole()
Section titled “revokeRole()”public function revokeRole(string $role): void
Revoke a role membership for this user.
The role name to remove from this user.
| Parameter | Type | Description |
|---|---|---|
$role | string | The role name to remove from this user. |
shutdown()
Section titled “shutdown()”public function shutdown(): void
Execute the shutdown procedure.
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
addCredential() | SecurityUser | Add a credential to this user. |
appendAttribute() | User | Appends a value to an array attribute and marks the user dirty. |
appendAttributeByRef() | User | Appends a value by reference to an array attribute and marks the user dirty. |
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearAttributes() | User | Removes every attribute in every namespace and marks the user dirty. |
clearCredentials() | SecurityUser | Clear all credentials associated with this user. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
getAttribute() | AttributeHolder | Retrieve an attribute. |
getAttributeNames() | AttributeHolder | Retrieve an array of attribute names. |
getAttributeNamespace() | AttributeHolder | Retrieve all attributes within a namespace. |
getAttributeNamespaces() | AttributeHolder | Retrieve an array of attribute namespaces. |
getAttributes() | AttributeHolder | Retrieve all attributes within a namespace. |
getContext() | User | Retrieve the current application context. |
getCredentials() | SecurityUser | Returns the list of credentials that this user possesses. |
getDefaultNamespace() | AttributeHolder | Get the default namespace name |
getFlatAttributeNames() | AttributeHolder | Retrieve an array of flattened attribute names. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
getStorageNamespace() | User | Retrieve the Storage namespace |
getTokenClaims() | SecurityUser | The validated claims this identity was resolved from, when RbacSecurityUser::isTokenDerived() is true. |
hasAttribute() | AttributeHolder | Indicates whether or not an attribute exists. |
hasAttributeNamespace() | AttributeHolder | Indicates whether or not an attribute namespace exists. |
hasCredential() | SecurityUser | Indicates whether or not this user has a credential. |
hasCredentials() | SecurityUser | Indicates whether or not this user has a credential or a set of credentials. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
isAuthenticated() | SecurityUser | Indicates whether or not this user is authenticated. |
isDirty() | User | Whether this request changed user state that still needs persisting. |
isTokenDerived() | SecurityUser | True when this user’s identity was (re-)established from a token rather than the session, per $tokenDerived. |
markClean() | User | Record that in-memory state now matches what is persisted. |
markDirty() | User | Force this user to be persisted at the request boundary. |
markTokenDerived() | SecurityUser | Mark (or clear) this user as token-derived, for this request only — the marker is not persisted (see $tokenDerived). |
persistAttributesImmediate() | User | Immediately persist current user attributes (or a filtered subset) to storage. |
removeAttribute() | User | Removes a single attribute and marks the user dirty so the removal is persisted. |
removeAttributeNamespace() | User | Removes a whole attribute namespace and marks the user dirty. |
removeCredential() | SecurityUser | Remove a credential from this user. |
removeParameter() | ParameterHolder | Remove a parameter. |
restoreContext() | User | Re-bind context after unserialization without re-running full initialize logic. |
restoreIdentityFromStorage() | SecurityUser | Re-populate this user’s core identity attributes (see CORE_IDENTITY_KEYS) from storage. |
setAttribute() | User | Sets an attribute and marks the user dirty so shutdown() persists it. |
setAttributeByRef() | User | Sets an attribute by reference and marks the user dirty. |
setAttributes() | User | Merges a set of attributes into a namespace and marks the user dirty. |
setAttributesByRef() | User | Merges a set of attributes by reference into a namespace and marks the user dirty. |
setAuthenticated() | SecurityUser | Set the authenticated status of this user. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |
setTokenClaims() | SecurityUser | Set (or clear) the validated claims this identity was resolved from. |
startup() | User | Startup the user. |