class UsernamePassword extends AbstractToken implements UsernamePasswordTokenInterface (View source)

An authentication token used for simple username and password authentication.

Constants

private DEFAULT_USERNAME_POST_FIELD

private DEFAULT_PASSWORD_POST_FIELD

Properties

protected string $authenticationProviderName from  AbstractToken
protected int $authenticationStatus

Current authentication status of this token

from  AbstractToken
protected array $credentials

The username/password credentials

protected Account $account from  AbstractToken
protected array $requestPatterns from  AbstractToken
protected EntryPointInterface $entryPoint

The authentication entry point

from  AbstractToken
protected array $options

Token options

from  AbstractToken

Methods

__construct(array $options = null)

Build an instance of this token, potentially passing it options that can be configured via tokenOptions

string
getAuthenticationProviderName()

Returns the name of the authentication provider responsible for this token

void
setAuthenticationProviderName(string $authenticationProviderName)

Sets the name of the authentication provider responsible for this token

bool
isAuthenticated()

Returns true if this token is currently authenticated

void
setAuthenticationEntryPoint(EntryPointInterface $entryPoint)

Sets the authentication entry point

getAuthenticationEntryPoint()

Returns the configured authentication entry point, NULL if none is available

bool
hasRequestPatterns()

Returns true if any request pattern has been defined

void
setRequestPatterns(array $requestPatterns)

Sets request patterns

getRequestPatterns()

Returns an array of set \Neos\Flow\Security\RequestPatternInterface, NULL if none was set

mixed
getCredentials()

Returns the credentials (username and password) of this token.

getAccount()

Returns the account if one is authenticated, NULL otherwise.

void
setAccount(Account $account = null)

Set the (authenticated) account

void
setAuthenticationStatus(int $authenticationStatus)

Sets the authentication status. Usually called by the responsible \Neos\Flow\Security\Authentication\AuthenticationManagerInterface

int
getAuthenticationStatus()

Returns the current authentication status

string
__toString()

Returns a string representation of the token for logging purposes.

void
updateCredentials(ActionRequest $actionRequest)

Updates the username and password credentials from the POST vars, if the POST parameters are available. Sets the authentication status to REAUTHENTICATION_NEEDED, if credentials have been sent.

string
getUsername()

No description

string
getPassword()

No description

Details

__construct(array $options = null)

Build an instance of this token, potentially passing it options that can be configured via tokenOptions

Parameters

array $options

string getAuthenticationProviderName()

Returns the name of the authentication provider responsible for this token

Return Value

string

The authentication provider name

void setAuthenticationProviderName(string $authenticationProviderName)

Sets the name of the authentication provider responsible for this token

Parameters

string $authenticationProviderName

The authentication provider name

Return Value

void

bool isAuthenticated()

Returns true if this token is currently authenticated

Return Value

bool

true if this this token is currently authenticated

void setAuthenticationEntryPoint(EntryPointInterface $entryPoint)

Sets the authentication entry point

Parameters

EntryPointInterface $entryPoint

The authentication entry point

Return Value

void

EntryPointInterface getAuthenticationEntryPoint()

Returns the configured authentication entry point, NULL if none is available

Return Value

EntryPointInterface

The configured authentication entry point, NULL if none is available

bool hasRequestPatterns()

Returns true if any request pattern has been defined

Return Value

bool

True if a \Neos\Flow\Security\RequestPatternInterface was set

void setRequestPatterns(array $requestPatterns)

Sets request patterns

Parameters

array $requestPatterns

Array of \Neos\Flow\Security\RequestPatternInterface to be set

Return Value

void

Exceptions

InvalidArgumentException

RequestPatternInterface[] getRequestPatterns()

Returns an array of set \Neos\Flow\Security\RequestPatternInterface, NULL if none was set

Return Value

RequestPatternInterface[]

Array of set request patterns

See also

hasRequestPattern()

mixed getCredentials()

Returns the credentials (username and password) of this token.

Return Value

mixed

$credentials The needed credentials to authenticate this token

Account getAccount()

Returns the account if one is authenticated, NULL otherwise.

Return Value

Account

An account object

void setAccount(Account $account = null)

Set the (authenticated) account

Parameters

Account $account

An account object

Return Value

void

void setAuthenticationStatus(int $authenticationStatus)

Sets the authentication status. Usually called by the responsible \Neos\Flow\Security\Authentication\AuthenticationManagerInterface

Parameters

int $authenticationStatus

One of NO_CREDENTIALS_GIVEN, WRONG_CREDENTIALS, AUTHENTICATION_SUCCESSFUL

Return Value

void

Exceptions

InvalidAuthenticationStatusException

int getAuthenticationStatus()

Returns the current authentication status

Return Value

int

One of NO_CREDENTIALS_GIVEN, WRONG_CREDENTIALS, AUTHENTICATION_SUCCESSFUL, REAUTHENTICATION_NEEDED

string __toString()

Returns a string representation of the token for logging purposes.

Return Value

string

A string representation of the token

void updateCredentials(ActionRequest $actionRequest)

Updates the username and password credentials from the POST vars, if the POST parameters are available. Sets the authentication status to REAUTHENTICATION_NEEDED, if credentials have been sent.

Note: You need to send the username and password in these two POST parameters: authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][username] and authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][password] or specify the "usernamePostField" and "passwordPostField" options in the provider configuration:

Neos: Flow: security: authentication: providers: DefaultProvider: provider: PersistedUsernamePasswordProvider tokenOptions: usernamePostField: 'some.argument' passwordPostField: 'some.other.argument'

Parameters

ActionRequest $actionRequest

The current request instance

Return Value

void

Exceptions

InvalidAuthenticationStatusException

string getUsername()

No description

Return Value

string

The username this token represents

string getPassword()

No description

Return Value

string

The password this token represents