PHP Класс Neos\Flow\Security\Context

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$activeTokens Neos\Flow\Security\Authentication\TokenInterface[] Array of tokens currently active
$authenticationManager Neos\Flow\Security\Authentication\AuthenticationManagerInterface
$authenticationStrategy integer One of the AUTHENTICATE_* constants to set the authentication strategy.
$authorizationChecksDisabled boolean Whether authorization is disabled @see areAuthorizationChecksDisabled()
$contextHash string @see getContextHash()
$csrfProtectionStrategy integer One of the CSRF_* constants to set the csrf protection strategy
$csrfProtectionTokens array
$hashService Neos\Flow\Security\Cryptography\HashService
$inactiveTokens array Array of tokens currently inactive
$initialized boolean TRUE if the context is initialized in the current request, FALSE or NULL otherwise.
$interceptedRequest Neos\Flow\Mvc\RequestInterface
$policyService Neos\Flow\Security\Policy\PolicyService
$request Neos\Flow\Mvc\ActionRequest
$roles Neos\Flow\Security\Policy\Role[]
$securityLogger Neos\Flow\Log\SecurityLoggerInterface
$sessionManager Neos\Flow\Session\SessionManagerInterface
$tokenStatusLabels array
$tokens array Array of configured tokens (might have request patterns)

Открытые методы

Метод Описание
areAuthorizationChecksDisabled ( ) : boolean Returns TRUE if authorization should be ignored, otherwise FALSE This is mainly useful to fetch records without Content Security to kick in (e.g. for AuthenticationProviders)
canBeInitialized ( ) : boolean Check if the securityContext is ready to be initialized. Only after that security will be active.
clearContext ( ) : void Clears the security context.
getAccount ( ) : Account Returns the account of the first authenticated authentication token.
getAccountByAuthenticationProviderName ( string $authenticationProviderName ) : Account Returns an authenticated account for the given provider or NULL if no account was authenticated or no token was registered for the given authentication provider name.
getAuthenticationStrategy ( ) : integer Get the token authentication strategy
getAuthenticationTokens ( ) : Neos\Flow\Security\Authentication\TokenInterface[] Returns all Authentication\Tokens of the security context which are active for the current request. If a token has a request pattern that cannot match against the current request it is determined as not active.
getAuthenticationTokensOfType ( string $className ) : Neos\Flow\Security\Authentication\TokenInterface[] Returns all Authentication\Tokens of the security context which are active for the current request and of the given type. If a token has a request pattern that cannot match against the current request it is determined as not active.
getContextHash ( ) : string Returns a hash that is unique for the current context, depending on hash components, @see setContextHashComponent()
getCsrfProtectionToken ( ) : string Returns the current CSRF protection token. A new one is created when needed, depending on the configured CSRF protection strategy.
getInterceptedRequest ( ) : ActionRequest Returns the request, that has been stored for later resuming after it has been intercepted by a security exception, NULL if there is none.
getRoles ( ) : Role[] Returns the roles of all authenticated accounts, including inherited roles.
hasCsrfProtectionTokens ( ) : boolean Returns TRUE if the context has CSRF protection tokens.
hasRole ( string $roleIdentifier ) : boolean Returns TRUE, if at least one of the currently authenticated accounts holds a role with the given identifier, also recursively.
initialize ( ) : void Initializes the security context for the given request.
injectAuthenticationManager ( Neos\Flow\Security\Authentication\AuthenticationManagerInterface $authenticationManager ) : void Inject the authentication manager
injectSettings ( array $settings ) : void Injects the configuration settings
isCsrfProtectionTokenValid ( string $csrfToken ) : boolean Returns TRUE if the given string is a valid CSRF protection token. The token will be removed if the configured csrf strategy is 'onePerUri'.
isInitialized ( ) : boolean
refreshRoles ( ) : void Refreshes the currently effective roles. In fact the roles first level cache is reset and the effective roles get recalculated by calling getRoles().
refreshTokens ( ) : void Refreshes all active tokens by updating the credentials.
setInterceptedRequest ( ActionRequest $interceptedRequest = null ) : void Sets an action request, to be stored for later resuming after it has been intercepted by a security exception.
setRequest ( ActionRequest $request ) : void Set the current action request
shutdownObject ( ) : void Shut the object down
withoutAuthorizationChecks ( Closure $callback ) : void Lets you switch off authorization checks (CSRF token, policies, content security, .

Защищенные методы

Метод Описание
isTokenActive ( Neos\Flow\Security\Authentication\TokenInterface $token ) : boolean Evaluates any RequestPatterns of the given token to determine whether it is active for the current request - If no RequestPattern is configured for this token, it is active - Otherwise it is active only if at least one configured RequestPattern per type matches the request
mergeTokens ( array $managerTokens, array $sessionTokens ) : array Merges the session and manager tokens. All manager tokens types will be in the result array If a specific type is found in the session this token replaces the one (of the same type) given by the manager.
separateActiveAndInactiveTokens ( ) : void Stores all active tokens in $this->activeTokens, all others in $this->inactiveTokens
updateTokens ( array $tokens ) : void Updates the token credentials for all tokens in the given array.

Описание методов

areAuthorizationChecksDisabled() публичный Метод

Returns TRUE if authorization should be ignored, otherwise FALSE This is mainly useful to fetch records without Content Security to kick in (e.g. for AuthenticationProviders)
См. также: withoutAuthorizationChecks()
public areAuthorizationChecksDisabled ( ) : boolean
Результат boolean

canBeInitialized() публичный Метод

To be able to initialize, there needs to be an ActionRequest available, usually that is provided by the MVC router.
public canBeInitialized ( ) : boolean
Результат boolean

clearContext() публичный Метод

Clears the security context.
public clearContext ( ) : void
Результат void

getAccount() публичный Метод

Note: There might be a more currently authenticated account in the remaining tokens. If you need them you'll have to fetch them directly from the tokens. (@see getAuthenticationTokens())
public getAccount ( ) : Account
Результат Account The authenticated account

getAccountByAuthenticationProviderName() публичный Метод

Returns an authenticated account for the given provider or NULL if no account was authenticated or no token was registered for the given authentication provider name.
public getAccountByAuthenticationProviderName ( string $authenticationProviderName ) : Account
$authenticationProviderName string Authentication provider name of the account to find
Результат Account The authenticated account

getAuthenticationStrategy() публичный Метод

Get the token authentication strategy
public getAuthenticationStrategy ( ) : integer
Результат integer One of the AUTHENTICATE_* constants

getAuthenticationTokens() публичный Метод

Returns all Authentication\Tokens of the security context which are active for the current request. If a token has a request pattern that cannot match against the current request it is determined as not active.
public getAuthenticationTokens ( ) : Neos\Flow\Security\Authentication\TokenInterface[]
Результат Neos\Flow\Security\Authentication\TokenInterface[] Array of set tokens

getAuthenticationTokensOfType() публичный Метод

Returns all Authentication\Tokens of the security context which are active for the current request and of the given type. If a token has a request pattern that cannot match against the current request it is determined as not active.
public getAuthenticationTokensOfType ( string $className ) : Neos\Flow\Security\Authentication\TokenInterface[]
$className string The class name
Результат Neos\Flow\Security\Authentication\TokenInterface[] Array of set tokens of the specified type

getContextHash() публичный Метод

Returns a hash that is unique for the current context, depending on hash components, @see setContextHashComponent()
public getContextHash ( ) : string
Результат string

getCsrfProtectionToken() публичный Метод

Returns the current CSRF protection token. A new one is created when needed, depending on the configured CSRF protection strategy.
public getCsrfProtectionToken ( ) : string
Результат string

getInterceptedRequest() публичный Метод

Returns the request, that has been stored for later resuming after it has been intercepted by a security exception, NULL if there is none.
public getInterceptedRequest ( ) : ActionRequest
Результат Neos\Flow\Mvc\ActionRequest

getRoles() публичный Метод

If no authenticated roles could be found the "Anonymous" role is returned. The "Neos.Flow:Everybody" roles is always returned.
public getRoles ( ) : Role[]
Результат Neos\Flow\Security\Policy\Role[]

hasCsrfProtectionTokens() публичный Метод

Returns TRUE if the context has CSRF protection tokens.
public hasCsrfProtectionTokens ( ) : boolean
Результат boolean TRUE, if the token is valid. FALSE otherwise.

hasRole() публичный Метод

Returns TRUE, if at least one of the currently authenticated accounts holds a role with the given identifier, also recursively.
public hasRole ( string $roleIdentifier ) : boolean
$roleIdentifier string The string representation of the role to search for
Результат boolean TRUE, if a role with the given string representation was found

initialize() публичный Метод

Initializes the security context for the given request.
public initialize ( ) : void
Результат void

injectAuthenticationManager() публичный Метод

Inject the authentication manager
public injectAuthenticationManager ( Neos\Flow\Security\Authentication\AuthenticationManagerInterface $authenticationManager ) : void
$authenticationManager Neos\Flow\Security\Authentication\AuthenticationManagerInterface The authentication manager
Результат void

injectSettings() публичный Метод

Injects the configuration settings
public injectSettings ( array $settings ) : void
$settings array
Результат void

isCsrfProtectionTokenValid() публичный Метод

Returns TRUE if the given string is a valid CSRF protection token. The token will be removed if the configured csrf strategy is 'onePerUri'.
public isCsrfProtectionTokenValid ( string $csrfToken ) : boolean
$csrfToken string The token string to be validated
Результат boolean TRUE, if the token is valid. FALSE otherwise.

isInitialized() публичный Метод

public isInitialized ( ) : boolean
Результат boolean TRUE if the Context is initialized, FALSE otherwise.

isTokenActive() защищенный Метод

Evaluates any RequestPatterns of the given token to determine whether it is active for the current request - If no RequestPattern is configured for this token, it is active - Otherwise it is active only if at least one configured RequestPattern per type matches the request
protected isTokenActive ( Neos\Flow\Security\Authentication\TokenInterface $token ) : boolean
$token Neos\Flow\Security\Authentication\TokenInterface
Результат boolean TRUE if the given token is active, otherwise FALSE

mergeTokens() защищенный Метод

Merges the session and manager tokens. All manager tokens types will be in the result array If a specific type is found in the session this token replaces the one (of the same type) given by the manager.
protected mergeTokens ( array $managerTokens, array $sessionTokens ) : array
$managerTokens array Array of tokens provided by the authentication manager
$sessionTokens array Array of tokens restored from the session
Результат array Array of Authentication\TokenInterface objects

refreshRoles() публичный Метод

Refreshes the currently effective roles. In fact the roles first level cache is reset and the effective roles get recalculated by calling getRoles().
public refreshRoles ( ) : void
Результат void

refreshTokens() публичный Метод

This is useful when doing an explicit authentication inside a request.
public refreshTokens ( ) : void
Результат void

separateActiveAndInactiveTokens() защищенный Метод

Stores all active tokens in $this->activeTokens, all others in $this->inactiveTokens
protected separateActiveAndInactiveTokens ( ) : void
Результат void

setInterceptedRequest() публичный Метод

Sets an action request, to be stored for later resuming after it has been intercepted by a security exception.
public setInterceptedRequest ( ActionRequest $interceptedRequest = null ) : void
$interceptedRequest Neos\Flow\Mvc\ActionRequest
Результат void

setRequest() публичный Метод

This method is called manually by the request handler which created the HTTP request.
public setRequest ( ActionRequest $request ) : void
$request Neos\Flow\Mvc\ActionRequest The current ActionRequest
Результат void

shutdownObject() публичный Метод

Shut the object down
public shutdownObject ( ) : void
Результат void

updateTokens() защищенный Метод

Updates the token credentials for all tokens in the given array.
protected updateTokens ( array $tokens ) : void
$tokens array Array of authentication tokens the credentials should be updated for
Результат void

withoutAuthorizationChecks() публичный Метод

..) for the runtime of $callback Usage: $this->securityContext->withoutAuthorizationChecks(function () use ($accountRepository, $username, $providerName, &$account) { this will disable the PersistenceQueryRewritingAspect for this one call $account = $accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($username, $providerName) });
public withoutAuthorizationChecks ( Closure $callback ) : void
$callback Closure
Результат void

Описание свойств

$activeTokens защищенное свойство

Array of tokens currently active
protected TokenInterface[],Neos\Flow\Security\Authentication $activeTokens
Результат Neos\Flow\Security\Authentication\TokenInterface[]

$authenticationManager защищенное свойство

protected AuthenticationManagerInterface,Neos\Flow\Security\Authentication $authenticationManager
Результат Neos\Flow\Security\Authentication\AuthenticationManagerInterface

$authenticationStrategy защищенное свойство

One of the AUTHENTICATE_* constants to set the authentication strategy.
protected int $authenticationStrategy
Результат integer

$authorizationChecksDisabled защищенное свойство

Whether authorization is disabled @see areAuthorizationChecksDisabled()
protected bool $authorizationChecksDisabled
Результат boolean

$contextHash защищенное свойство

@see getContextHash()
protected string $contextHash
Результат string

$csrfProtectionStrategy защищенное свойство

One of the CSRF_* constants to set the csrf protection strategy
protected int $csrfProtectionStrategy
Результат integer

$csrfProtectionTokens защищенное свойство

protected array $csrfProtectionTokens
Результат array

$hashService защищенное свойство

protected HashService,Neos\Flow\Security\Cryptography $hashService
Результат Neos\Flow\Security\Cryptography\HashService

$inactiveTokens защищенное свойство

Array of tokens currently inactive
protected array $inactiveTokens
Результат array

$initialized защищенное свойство

TRUE if the context is initialized in the current request, FALSE or NULL otherwise.
protected bool $initialized
Результат boolean

$interceptedRequest защищенное свойство

protected RequestInterface,Neos\Flow\Mvc $interceptedRequest
Результат Neos\Flow\Mvc\RequestInterface

$policyService защищенное свойство

protected PolicyService,Neos\Flow\Security\Policy $policyService
Результат Neos\Flow\Security\Policy\PolicyService

$request защищенное свойство

protected ActionRequest,Neos\Flow\Mvc $request
Результат Neos\Flow\Mvc\ActionRequest

$roles защищенное свойство

protected Role[],Neos\Flow\Security\Policy $roles
Результат Neos\Flow\Security\Policy\Role[]

$securityLogger защищенное свойство

protected SecurityLoggerInterface,Neos\Flow\Log $securityLogger
Результат Neos\Flow\Log\SecurityLoggerInterface

$sessionManager защищенное свойство

protected SessionManagerInterface,Neos\Flow\Session $sessionManager
Результат Neos\Flow\Session\SessionManagerInterface

$tokenStatusLabels защищенное свойство

protected array $tokenStatusLabels
Результат array

$tokens защищенное свойство

Array of configured tokens (might have request patterns)
protected array $tokens
Результат array