Phalcon auth
NOTE
All classes are prefixed with Phalcon
Auth\AbstractAuthDispatcherListener¶
Abstract Source on GitHub
Shared enforcement algorithm for the Cli and Mvc auth dispatcher listeners. The dispatcher-specific subclass provides only the action name from its typed dispatcher, the action-kind label used in the access-denied exception, and (Mvc only) a forward handler for Access::redirectTo().
Phalcon\Auth\AbstractAuthDispatcherListener
Uses Phalcon\Auth\Exceptions\AccessDenied · Phalcon\Contracts\Auth\Manager
Method Summary¶
public __construct( Manager $manager ) protected bool enforce(string $actionName,mixed $forwardHandler = null) Runs the access check for the given action name. Returns true when protected string getActionType() Returns the kind label used by AccessDenied (e.g. 'task', Properties¶
protected Manager $manager Methods¶
__construct()¶
enforce()¶
Runs the access check for the given action name. Returns true when the dispatch should proceed, false when a forward was issued, and throws when access is denied without a redirect target.
getActionType()¶
Returns the kind label used by AccessDenied (e.g. 'task', 'action').
Auth\Access\AbstractAccess¶
Abstract Source on GitHub
Phalcon\Auth\Access\AbstractAccess— implementsPhalcon\Contracts\Auth\Access\Access
Uses Phalcon\Contracts\Auth\Access\Access · Phalcon\Contracts\Auth\Manager
Method Summary¶
public __construct( Manager $manager ) public array getExceptActions() public array getOnlyActions() public bool isAllowed( string $actionName ) public array|null redirectTo() public void setExceptActions( array $exceptActions = [] ) public void setOnlyActions( array $onlyActions = [] ) Properties¶
protected array $exceptActions = [] protected Manager $manager protected array $onlyActions = [] Methods¶
__construct()¶
getExceptActions()¶
getOnlyActions()¶
isAllowed()¶
redirectTo()¶
setExceptActions()¶
setOnlyActions()¶
Auth\Access\AccessLocator¶
Class Source on GitHub
Service locator for Phalcon\Auth access gates. Utilizes the container to obtain the service. For the Phalcon\Container\Container one can use autowiring. For the Phalcon\Di\Di, one needs to register the gates in it to be used here.
@extends AbstractLocator
Phalcon\Support\AbstractLocatorPhalcon\Auth\Access\AccessLocator
Uses Phalcon\Contracts\Auth\Access\Access · Phalcon\Support\AbstractLocator
Method Summary¶
protected string getExceptionClass() protected string getInterfaceClass() protected array getServices() Methods¶
getExceptionClass()¶
getInterfaceClass()¶
getServices()¶
Auth\Access\Auth¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Access\AbstractAccessPhalcon\Auth\Access\Auth
Method Summary¶
Methods¶
allowedIf()¶
Auth\Access\Guest¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Access\AbstractAccessPhalcon\Auth\Access\Guest
Method Summary¶
Methods¶
allowedIf()¶
Auth\Adapter\AbstractAdapter¶
Abstract Source on GitHub
@template TConfig of AdapterConfig
Phalcon\Auth\Adapter\AbstractAdapter— implementsPhalcon\Contracts\Auth\Adapter\Adapter
Uses Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\Adapter\AdapterConfig · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Encryption\Security\Security
Method Summary¶
public __construct(Security $hasher,AdapterConfig $config) public AdapterConfig getConfig() Returns the adapter configuration object. public string|null getModel() Returns the model class name, if configured. public bool validateCredentials(AuthUser $user,array $credentials) Validates the supplied plaintext password against the user's stored hash. Properties¶
protected AdapterConfig $config protected Security $hasher Methods¶
__construct()¶
getConfig()¶
Returns the adapter configuration object.
getModel()¶
Returns the model class name, if configured.
validateCredentials()¶
Validates the supplied plaintext password against the user's stored hash. Concrete adapters share this implementation; if your data source needs a different verification strategy, override it.
Auth\Adapter\AbstractArrayAdapter¶
Abstract Source on GitHub
Common base for adapters whose user records come from an in-memory list (Memory and Stream). Subclasses provide the row source via loadUsers(); everything else - credentials matching, hydration, the empty-credentials guard, and a default linear retrieveById - is shared here.
@template TConfig of AdapterConfig @extends AbstractAdapter
Phalcon\Auth\Adapter\AbstractAdapterPhalcon\Auth\Adapter\AbstractArrayAdapter
Uses Phalcon\Auth\AuthUser · Phalcon\Contracts\Auth\Adapter\AdapterConfig · Phalcon\Contracts\Auth\AuthUser
Method Summary¶
public AuthUserContract|null retrieveByCredentials( array $credentials ) Walks the user list and returns the first row whose non-'password' public AuthUserContract|null retrieveById( mixed $id ) Default linear-scan implementation. Memory overrides this for an O(1) protected bool hasIdentifyingField( array $credentials ) Tests whether a credentials payload carries at least one identifying protected AuthUserContract hydrate( array $row ) Hydrates a raw user row into either the configured model class or a protected array loadUsers() Returns the source list of user rows. Concrete subclasses decide protected bool matchesRow(array $row,array $credentials) Strict per-key match of a row against credentials, skipping 'password'. Methods¶
retrieveByCredentials()¶
Walks the user list and returns the first row whose non-'password' keys all match strictly. Returns null when no row matches or when $credentials carries no identifying field at all (only 'password', or empty) - protects callers from the silent "first row wins" footgun.
retrieveById()¶
Default linear-scan implementation. Memory overrides this for an O(1) id-keyed lookup; Stream uses this as-is.
hasIdentifyingField()¶
Tests whether a credentials payload carries at least one identifying field (i.e. anything other than 'password'). An empty payload - or a payload that only contains 'password' - is treated as "no lookup".
hydrate()¶
Hydrates a raw user row into either the configured model class or a Phalcon\Auth\AuthUser value object.
loadUsers()¶
Returns the source list of user rows. Concrete subclasses decide where they come from (config array, JSON file, etc.).
matchesRow()¶
Strict per-key match of a row against credentials, skipping 'password'.
Auth\Adapter\AdapterLocator¶
Class Source on GitHub
Service locator for Phalcon\Auth adapters. Utilizes the container to obtain the service. For the Phalcon\Container\Container one can use autowiring. For the Phalcon\Di\Di, one needs to register the gates in it to be used here.
@extends AbstractLocator
Phalcon\Support\AbstractLocatorPhalcon\Auth\Adapter\AdapterLocator
Uses Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Support\AbstractLocator
Method Summary¶
protected string getExceptionClass() protected string getInterfaceClass() protected array getServices() Methods¶
getExceptionClass()¶
getInterfaceClass()¶
getServices()¶
Auth\Adapter\Config\AbstractAdapterConfig¶
Abstract Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Adapter\Config\AbstractAdapterConfig— implementsPhalcon\Contracts\Auth\Adapter\AdapterConfig
Uses Phalcon\Contracts\Auth\Adapter\AdapterConfig
Method Summary¶
Properties¶
protected string|null $model = null Methods¶
__construct()¶
getModel()¶
Auth\Adapter\Config\MemoryAdapterConfig¶
Class Source on GitHub
Phalcon\Auth\Adapter\Config\AbstractAdapterConfigPhalcon\Auth\Adapter\Config\MemoryAdapterConfig
Method Summary¶
Properties¶
protected array $users = [] Methods¶
__construct()¶
getUsers()¶
Auth\Adapter\Config\ModelAdapterConfig¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Adapter\Config\AbstractAdapterConfigPhalcon\Auth\Adapter\Config\ModelAdapterConfig
Uses Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\ConfigRequiresNonEmptyValue
Method Summary¶
public __construct(string $model,string $idColumn = "id") public string getIdColumn() public string getModel() Properties¶
protected string $idColumn = "id" Methods¶
__construct()¶
getIdColumn()¶
getModel()¶
Auth\Adapter\Config\StreamAdapterConfig¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Adapter\Config\AbstractAdapterConfigPhalcon\Auth\Adapter\Config\StreamAdapterConfig
Uses Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\ConfigRequiresNonEmptyValue
Method Summary¶
Properties¶
protected string $file Methods¶
__construct()¶
getFile()¶
Auth\Adapter\Memory¶
Class Source on GitHub
In-memory adapter - useful for tests and small read-only user lists.
@extends AbstractArrayAdapter
Phalcon\Auth\Adapter\AbstractAdapterPhalcon\Auth\Adapter\AbstractArrayAdapterPhalcon\Auth\Adapter\Memory
Uses Phalcon\Auth\Adapter\Config\MemoryAdapterConfig · Phalcon\Auth\Internal\Options · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Encryption\Security\Security
Method Summary¶
public __construct(Security $hasher,MemoryAdapterConfig $config) public static fromOptions(Security $hasher,array $options) public AuthUser|null retrieveById( mixed $id ) Overridden for O(1) lookup via the id index built in the constructor. protected array loadUsers() Methods¶
__construct()¶
fromOptions()¶
retrieveById()¶
Overridden for O(1) lookup via the id index built in the constructor.
loadUsers()¶
Auth\Adapter\Model¶
Class Source on GitHub
Phalcon Model-backed adapter.
@extends AbstractAdapter
Phalcon\Auth\Adapter\AbstractAdapterPhalcon\Auth\Adapter\Model— implementsPhalcon\Contracts\Auth\Adapter\RememberAdapter
Uses Phalcon\Auth\Adapter\Config\ModelAdapterConfig · Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\DoesNotImplement · Phalcon\Auth\Internal\Options · Phalcon\Contracts\Auth\Adapter\RememberAdapter · Phalcon\Contracts\Auth\AuthRemember · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Auth\RememberToken · Phalcon\Contracts\Encryption\Security\Security · Phalcon\Mvc\ModelInterface
Method Summary¶
public __construct(Security $hasher,ModelAdapterConfig $config) public RememberToken createRememberToken( AuthUser $user ) Create and persist a new remember token for the user. public static fromOptions(Security $hasher,array $options) public AuthUser|null retrieveByCredentials( array $credentials ) Find a user matching the given credentials (excluding 'password' key). public AuthUser|null retrieveById( mixed $id ) public AuthUser|null retrieveByToken(mixed $id,string $token,string $userAgent = null) Retrieve a user by the remember-me cookie payload. Methods¶
__construct()¶
createRememberToken()¶
Create and persist a new remember token for the user.
fromOptions()¶
retrieveByCredentials()¶
Find a user matching the given credentials (excluding 'password' key).
retrieveById()¶
retrieveByToken()¶
public function retrieveByToken(
mixed $id,
string $token,
string $userAgent = null
): AuthUser|null;
Retrieve a user by the remember-me cookie payload.
Auth\Adapter\Stream¶
Class Source on GitHub
JSON file-backed adapter.
The file must contain a JSON array of user records: [{"id":1,"email":"a@b","password":"
@extends AbstractArrayAdapter
Phalcon\Auth\Adapter\AbstractAdapterPhalcon\Auth\Adapter\AbstractArrayAdapterPhalcon\Auth\Adapter\Stream
Uses InvalidArgumentException · Phalcon\Auth\Adapter\Config\StreamAdapterConfig · Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\FileCannotRead · Phalcon\Auth\Exceptions\FileDoesNotContainJson · Phalcon\Auth\Exceptions\FileDoesNotExist · Phalcon\Auth\Exceptions\FileNotValidJson · Phalcon\Auth\Internal\Options · Phalcon\Contracts\Encryption\Security\Security · Phalcon\Support\Helper\Json\Decode
Method Summary¶
public __construct(Security $hasher,StreamAdapterConfig $config) public static fromOptions(Security $hasher,array $options) protected array loadUsers() Loads and decodes the JSON users file. Re-read on every call - if you protected bool phpFileExists( string $filename ) protected phpFileGetContents( string $filename ) Methods¶
__construct()¶
fromOptions()¶
loadUsers()¶
Loads and decodes the JSON users file. Re-read on every call - if you need caching, wrap it.
phpFileExists()¶
phpFileGetContents()¶
Auth\AuthUser¶
Class Source on GitHub
Lightweight value object returned by array-backed adapters (Memory, Stream) when no application model class is configured.
Phalcon\Auth\AuthUser— implementsPhalcon\Contracts\Auth\AuthUser
Uses Phalcon\Auth\Exceptions\DataMustContainIdKey · Phalcon\Contracts\Auth\AuthUser
Method Summary¶
public __construct( array $data ) public int|string getAuthIdentifier() public string getAuthPassword() public array toArray() Returns the underlying data array. Properties¶
protected array $data Methods¶
__construct()¶
getAuthIdentifier()¶
getAuthPassword()¶
toArray()¶
Returns the underlying data array.
Auth\Cli\AuthDispatcherListener¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\AbstractAuthDispatcherListenerPhalcon\Auth\Cli\AuthDispatcherListener
Uses Phalcon\Auth\AbstractAuthDispatcherListener · Phalcon\Auth\Exception · Phalcon\Cli\Dispatcher · Phalcon\Events\Event
Method Summary¶
public bool beforeExecuteRoute(Event $event,Dispatcher $dispatcher) protected string getActionType() Methods¶
beforeExecuteRoute()¶
getActionType()¶
Auth\Exception¶
Class Source on GitHub
Exceptions thrown in Phalcon\Auth will use this class
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\AccessDeniedPhalcon\Auth\Exceptions\ConfigRequiresNonEmptyValuePhalcon\Auth\Exceptions\DataMustContainIdKeyPhalcon\Auth\Exceptions\DoesNotImplementPhalcon\Auth\Exceptions\FileCannotReadPhalcon\Auth\Exceptions\FileDoesNotContainJsonPhalcon\Auth\Exceptions\FileDoesNotExistPhalcon\Auth\Exceptions\FileNotValidJson
Auth\Exceptions\AccessDenied¶
Class Source on GitHub
Access denied exception
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\AccessDenied
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\ConfigRequiresNonEmptyValue¶
Class Source on GitHub
Config requires non-empty value
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\ConfigRequiresNonEmptyValue
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\DataMustContainIdKey¶
Class Source on GitHub
AuthUser data must contain "id"
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\DataMustContainIdKey
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\DoesNotImplement¶
Class Source on GitHub
Does not implement interface
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\DoesNotImplement
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\FileCannotRead¶
Class Source on GitHub
Cannot read file
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\FileCannotRead
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\FileDoesNotContainJson¶
Class Source on GitHub
File does not contain a JSON array
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\FileDoesNotContainJson
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\FileDoesNotExist¶
Class Source on GitHub
File does not exist
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\FileDoesNotExist
Uses Phalcon\Auth\Exception
Method Summary¶
Methods¶
__construct()¶
Auth\Exceptions\FileNotValidJson¶
Class Source on GitHub
Not a valid JSON
\ExceptionPhalcon\Auth\ExceptionPhalcon\Auth\Exceptions\FileNotValidJson
Uses Phalcon\Auth\Exception · Throwable
Method Summary¶
Methods¶
__construct()¶
Auth\Guard\AbstractGuard¶
Abstract Source on GitHub
@template TConfig of GuardConfig
Phalcon\Events\AbstractEventsAwarePhalcon\Auth\Guard\AbstractGuard— implementsPhalcon\Contracts\Auth\Guard\Guard
Uses Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Auth\Guard\Guard · Phalcon\Contracts\Auth\Guard\GuardConfig · Phalcon\Events\AbstractEventsAware
Method Summary¶
public __construct(Adapter $adapter,GuardConfig $config) public bool check() public Adapter getAdapter() public GuardConfig getConfig() Returns the guard configuration object. public AuthUser|null getLastUserAttempted() public bool guest() public bool hasUser() public int|string|null id() public static setAdapter( Adapter $adapter ) public static setUser( AuthUser $user ) protected bool hasValidCredentials(mixed $user,array $credentials) user should be ?AuthUser Properties¶
protected Adapter $adapter protected GuardConfig $config protected AuthUser | null $lastUserAttempted = null protected AuthUser | null $user = null Methods¶
__construct()¶
check()¶
getAdapter()¶
getConfig()¶
Returns the guard configuration object.
getLastUserAttempted()¶
guest()¶
hasUser()¶
id()¶
setAdapter()¶
setUser()¶
hasValidCredentials()¶
user should be ?AuthUser
Auth\Guard\Config\AbstractGuardConfig¶
Abstract Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Guard\Config\AbstractGuardConfig— implementsPhalcon\Contracts\Auth\Guard\GuardConfig
Uses Phalcon\Contracts\Auth\Guard\GuardConfig
Auth\Guard\Config\SessionGuardConfig¶
Class Source on GitHub
Configuration for the Session guard. Holds the names under which the session key and remember-me cookie are stored. Defaults to 'auth' and 'remember'; multi-guard apps can pass a $suffix ('web', 'admin', ...) to derive 'auth_web' / 'remember_web' style names, or override either full name explicitly.
Phalcon\Auth\Guard\Config\AbstractGuardConfigPhalcon\Auth\Guard\Config\SessionGuardConfig
Uses Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\ConfigRequiresNonEmptyValue
Method Summary¶
public __construct(string $suffix = null,string $name = null,string $rememberName = null) public string getName() public string getRememberName() Methods¶
__construct()¶
public function __construct(
string $suffix = null,
string $name = null,
string $rememberName = null
);
getName()¶
getRememberName()¶
Auth\Guard\Config\TokenGuardConfig¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Implementation of this file has been influenced by sinbadxiii/cphalcon-auth @link https://github.com/sinbadxiii/cphalcon-auth
Phalcon\Auth\Guard\Config\AbstractGuardConfigPhalcon\Auth\Guard\Config\TokenGuardConfig
Uses Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\ConfigRequiresNonEmptyValue
Method Summary¶
public __construct(string $inputKey,string $storageKey) public string getInputKey() public string getStorageKey() Properties¶
protected string $inputKey protected string $storageKey Methods¶
__construct()¶
getInputKey()¶
getStorageKey()¶
Auth\Guard\GuardLocator¶
Class Source on GitHub
Service locator for Phalcon\Auth guards. Utilizes the container to obtain the service. For Phalcon\Container\Container one can use autowiring; for Phalcon\Di\Di, register the guards in it before resolution.
@extends AbstractLocator
Phalcon\Support\AbstractLocatorPhalcon\Auth\Guard\GuardLocator
Uses Phalcon\Contracts\Auth\Guard\Guard · Phalcon\Support\AbstractLocator
Method Summary¶
protected string getExceptionClass() protected string getInterfaceClass() protected array getServices() Methods¶
getExceptionClass()¶
getInterfaceClass()¶
getServices()¶
Auth\Guard\Session¶
Class Source on GitHub
@extends AbstractGuard
Phalcon\Events\AbstractEventsAwarePhalcon\Auth\Guard\AbstractGuardPhalcon\Auth\Guard\Session— implementsPhalcon\Contracts\Auth\Guard\GuardStateful,Phalcon\Contracts\Auth\Guard\BasicAuth
Uses Phalcon\Auth\Exception · Phalcon\Auth\Exceptions\DoesNotImplement · Phalcon\Auth\Guard\Config\SessionGuardConfig · Phalcon\Auth\Internal\Options · Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\Adapter\RememberAdapter · Phalcon\Contracts\Auth\AuthRemember · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Auth\Guard\BasicAuth · Phalcon\Contracts\Auth\Guard\GuardStateful · Phalcon\Contracts\Auth\RememberToken · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface · Phalcon\Http\RequestInterface · Phalcon\Http\Response\CookiesInterface · Phalcon\Session\ManagerInterface · Phalcon\Support\Helper\Json\Encode
Method Summary¶
public __construct(Adapter $adapter,RequestInterface $request,CookiesInterface $cookies,SessionManagerInterface $session,SessionGuardConfig $config = null) public bool attempt(array $credentials = [],bool $remember = false) public bool basic(string $field = "email",array $extraConditions = []) public static fromOptions(Adapter $adapter,mixed $container,array $options) public string getName() public string getRememberName() public void login(AuthUser $user,bool $remember = false) public false|AuthUser loginById(mixed $id,bool $remember = false) public void logout() public bool once( array $credentials = [] ) public false|AuthUser onceBasic(string $field = "email",array $extraConditions = []) public AuthUser|null user() public bool validate( array $credentials = [] ) public bool viaRemember() protected bool attemptBasic(string $field,array $extraConditions = []) protected array|null basicCredentials( string $field ) protected RememberToken createRememberToken( AuthUser $user ) protected UserRemember|null recaller() protected void rememberUser( AuthUser $user ) protected AuthUser|null userFromRecaller( UserRemember $recaller ) Properties¶
protected CookiesInterface $cookies protected RequestInterface $request protected SessionManagerInterface $session protected bool $viaRemember = false Methods¶
__construct()¶
public function __construct(
Adapter $adapter,
RequestInterface $request,
CookiesInterface $cookies,
SessionManagerInterface $session,
SessionGuardConfig $config = null
);
attempt()¶
basic()¶
fromOptions()¶
getName()¶
getRememberName()¶
login()¶
loginById()¶
logout()¶
once()¶
onceBasic()¶
user()¶
validate()¶
viaRemember()¶
attemptBasic()¶
basicCredentials()¶
createRememberToken()¶
recaller()¶
rememberUser()¶
userFromRecaller()¶
Auth\Guard\Token¶
Class Source on GitHub
@extends AbstractGuard
Phalcon\Events\AbstractEventsAwarePhalcon\Auth\Guard\AbstractGuardPhalcon\Auth\Guard\Token
Uses Phalcon\Auth\Guard\Config\TokenGuardConfig · Phalcon\Auth\Internal\Options · Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface · Phalcon\Http\RequestInterface
Method Summary¶
public __construct(Adapter $adapter,RequestInterface $request,TokenGuardConfig $config) public static fromOptions(Adapter $adapter,mixed $container,array $options) public string|null getTokenForRequest() public static setRequest( RequestInterface $request ) public AuthUser|null user() public bool validate( array $credentials = [] ) Properties¶
protected RequestInterface $request Methods¶
__construct()¶
public function __construct(
Adapter $adapter,
RequestInterface $request,
TokenGuardConfig $config
);
fromOptions()¶
getTokenForRequest()¶
setRequest()¶
user()¶
validate()¶
Auth\Guard\UserRemember¶
Final Source on GitHub
Value object representing the contents of a remember-me cookie.
Phalcon\Auth\Guard\UserRemember
Uses InvalidArgumentException · Phalcon\Support\Helper\Json\Decode
Method Summary¶
public __construct( mixed $payload ) Accepts either the raw JSON cookie value (string) or the already public int|string|null getId() public string getToken() public string getUserAgent() Properties¶
protected int|string|null $id protected string $token protected string $userAgent Methods¶
__construct()¶
Accepts either the raw JSON cookie value (string) or the already decoded associative array. Malformed input degrades to an empty payload so callers can read getters without null-guarding.
getId()¶
getToken()¶
getUserAgent()¶
Auth\Internal\Options¶
Final Source on GitHub
Internal option-parsing helpers shared by adapter / guard fromOptions() implementations. Not part of the public API.
Phalcon\Auth\Internal\Options
Uses Phalcon\Auth\Exception · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface
Method Summary¶
public array arrayOption(array $options,string $key,array $defaultValue) public string requireString(array $options,string $key,string $context) public object resolveService(mixed $container,string $serviceId,string $context) @template T of object public string|null stringOrNull(array $options,string $key) Methods¶
arrayOption()¶
requireString()¶
resolveService()¶
public static function resolveService(
mixed $container,
string $serviceId,
string $context
): object;
@template T of object
stringOrNull()¶
Auth\Manager¶
Class Source on GitHub
Composes guards (authentication) and access gates (authorization) behind a single facade. Guard-specific behavior is reached through Manager::guard(); callers narrow with instanceof against the relevant capability interface (GuardStateful, BasicAuth, etc.).
Phalcon\Auth\Manager— implementsPhalcon\Contracts\Auth\Manager
Uses Phalcon\Auth\Access\AccessLocator · Phalcon\Contracts\Auth\Access\Access · Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Auth\Guard\Guard · Phalcon\Contracts\Auth\Guard\GuardStateful · Phalcon\Contracts\Auth\Manager
Method Summary¶
public __construct( AccessLocator $accessFactory ) public self access( string $accessName ) public self addAccessList( array $accessList ) public self addGuard(string $nameGuard,Guard $guard,bool $isDefault = false) public bool attempt(array $credentials = [],bool $remember = false) public bool check() public self except( string $actions ) public Access|null getAccess() public array getAccessList() public Guard|null getDefaultGuard() public array getGuards() public Guard guard( string $name = null ) public int|string|null id() public void logout() public self only( string $actions ) public self setAccess( Access $access ) public self setDefaultGuard( Guard $guard ) public AuthUser|null user() public bool validate( array $credentials = [] ) Properties¶
protected AccessLocator $accessFactory protected Access | null $activeAccess = null protected Guard | null $defaultGuard = null protected array<string, Guard> $guards = [] Methods¶
__construct()¶
access()¶
addAccessList()¶
addGuard()¶
attempt()¶
check()¶
except()¶
getAccess()¶
getAccessList()¶
getDefaultGuard()¶
getGuards()¶
guard()¶
id()¶
logout()¶
only()¶
setAccess()¶
setDefaultGuard()¶
user()¶
validate()¶
Auth\ManagerFactory¶
Class Source on GitHub
Single entry-point factory that builds a fully wired Phalcon\Auth\Manager from a config tree. Framework-shared services (RequestInterface, CookiesInterface, SessionManagerInterface) are resolved from the injected container so the manager wires against the real application singletons, not separately constructed copies.
[ 'guards' => [ 'web' => [ 'type' => 'session', 'default' => true, 'adapter' => [ 'name' => 'model', 'options' => [ 'model' => User::class ], ], 'options' => [], ], 'api' => [ 'type' => 'token', 'adapter' => [ 'name' => 'model', 'options' => [ 'model' => User::class ] ], 'options' => [ 'inputKey' => 'api_token', 'storageKey' => 'api_token' ], ], ], 'access' => [ 'auth' => \Phalcon\Auth\Access\Auth::class, 'guest' => \Phalcon\Auth\Access\Guest::class, ], ]
Phalcon\Auth\ManagerFactory
Uses Phalcon\Auth\Access\AccessLocator · Phalcon\Auth\Adapter\AdapterLocator · Phalcon\Auth\Guard\GuardLocator · Phalcon\Config\ConfigInterface · Phalcon\Contracts\Auth\Access\Access · Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\Guard\Guard · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface · Phalcon\Encryption\Security
Method Summary¶
public __construct(Security $hasher,mixed $container,AdapterLocator $adapterLocator = null,GuardLocator $guardLocator = null,AccessLocator $accessLocator = null) public Manager load( mixed $config ) protected Adapter buildAdapter(AdapterLocator $locator,array $cfg) protected Guard buildGuard(GuardLocator $locator,string $type,Adapter $adapter,array $options) Properties¶
protected AccessLocator $accessLocator protected AdapterLocator $adapterLocator protected Collection $container protected GuardLocator $guardLocator protected Security $hasher Methods¶
__construct()¶
public function __construct(
Security $hasher,
mixed $container,
AdapterLocator $adapterLocator = null,
GuardLocator $guardLocator = null,
AccessLocator $accessLocator = null
);
load()¶
buildAdapter()¶
buildGuard()¶
protected function buildGuard(
GuardLocator $locator,
string $type,
Adapter $adapter,
array $options
): Guard;
Auth\Mvc\AuthDispatcherListener¶
Class Source on GitHub
Listener that enforces the active Phalcon\Auth access gate on each MVC dispatch. Attach to the events manager:
$eventsManager->attach('dispatch', new AuthDispatcherListener($manager));
No-op when no active access has been set on the manager.
Phalcon\Auth\AbstractAuthDispatcherListenerPhalcon\Auth\Mvc\AuthDispatcherListener
Uses Phalcon\Auth\AbstractAuthDispatcherListener · Phalcon\Auth\Exception · Phalcon\Events\Event · Phalcon\Mvc\Dispatcher
Method Summary¶
public bool beforeExecuteRoute(Event $event,Dispatcher $dispatcher) protected string getActionType()