Skip to content

Security

Dispatcher listener that enforces configured ACL permissions.

The listener compares the active controller/task class and action against PhalconKit ACL components. When permissions are not configured it allows the request, preserving the framework's permissive default for applications that have not opted into ACL configuration.


Methods

beforeDispatchLoop

Check ACL permissions before Phalcon enters the dispatch loop.

public beforeDispatchLoop(\Phalcon\Events\Event $event, \Phalcon\Dispatcher\AbstractDispatcher $dispatcher): bool

Parameters:

Parameter Type Description
$event \Phalcon\Events\Event Dispatch event emitted by Phalcon.
$dispatcher \Phalcon\Dispatcher\AbstractDispatcher Active MVC or CLI dispatcher.

Return Value:

True when dispatch can continue, false after forwarding.

Throws:

When dispatcher state cannot be inspected. - Exception


checkAcl

Determine whether the current identity may execute the active handler.

public checkAcl(\Phalcon\Events\Event $event, \Phalcon\Dispatcher\AbstractDispatcher|null $dispatcher = null): bool

A denied request from a signed-in identity is forwarded to router.forbidden (403 by default); a denied request without one is forwarded to router.unauthorized (401), telling the client to authenticate. Missing ACL components forward to router.notFound.

Parameters:

Parameter Type Description
$event \Phalcon\Events\Event Dispatch event emitted by Phalcon.
$dispatcher \Phalcon\Dispatcher\AbstractDispatcher|null Dispatcher to inspect. When
omitted, the injected dispatcher service is used.

Return Value:

True when dispatch can continue, false after forwarding.

Throws:

When dispatcher state cannot be inspected. - Exception


isCurrentRoute

Detect dispatcher cycles for full or partial configured routes.

private isCurrentRoute(array $route, ?string $namespace, ?string $module, string $handlerRouteKey, ?string $handler, string $action): bool

Parameters:

Parameter Type Description
$route array
$namespace ?string
$module ?string
$handlerRouteKey string
$handler ?string
$action string

resolveAclComponent

Resolve the configured ACL component for the current dispatcher handler.

private resolveAclComponent(\Phalcon\Acl\Adapter\Memory $acl, array<int,string> $candidates): ?string

Parameters:

Parameter Type Description
$acl \Phalcon\Acl\Adapter\Memory Native ACL instance.
$candidates array Handler class and route aliases.

usesControllerAttributes

Determine whether controller attributes should augment permission config.

private usesControllerAttributes(): bool

isAuthenticated

Whether the current identity has a signed-in user.

private isAuthenticated(): bool

Identity services without isLoggedIn() are treated as anonymous, so a denial is reported as 401 Unauthorized.