class SecurityHelper implements ProtectedContextAwareInterface (View source)

Helper for security related information

Properties

protected Context $securityContext
protected PrivilegeManagerInterface $privilegeManager

Methods

Account|null
getAccount()

Get the account of the first authenticated token.

string
csrfToken()

Returns CSRF token which is required for "unsafe" requests (e.g. POST, PUT, DELETE, ...)

bool
isAuthenticated()

Returns true, if any account is currently authenticated

bool
hasAccess(string $privilegeTarget, array $parameters = [])

Returns true, if access to the given privilege-target is granted

bool
hasRole(string $roleIdentifier)

Returns true, if at least one of the currently authenticated accounts holds a role with the given identifier, also recursively.

bool
allowsCallOfMethod(string $methodName)

All methods are considered safe

Details

Account|null getAccount()

Get the account of the first authenticated token.

Return Value

Account|null

string csrfToken()

Returns CSRF token which is required for "unsafe" requests (e.g. POST, PUT, DELETE, ...)

Return Value

string

bool isAuthenticated()

Returns true, if any account is currently authenticated

Return Value

bool

true if any account is authenticated

bool hasAccess(string $privilegeTarget, array $parameters = [])

Returns true, if access to the given privilege-target is granted

Parameters

string $privilegeTarget

The identifier of the privilege target to decide on

array $parameters

Optional array of privilege parameters (simple key => value array)

Return Value

bool

true if access is granted, false otherwise

bool hasRole(string $roleIdentifier)

Returns true, if at least one of the currently authenticated accounts holds a role with the given identifier, also recursively.

Parameters

string $roleIdentifier

The string representation of the role to search for

Return Value

bool

true, if a role with the given string representation was found

bool allowsCallOfMethod(string $methodName)

All methods are considered safe

Parameters

string $methodName

Return Value

bool