Docs / Sources / HTTP Kernel

HTTP Kernel

Record each access to a controller.

Enable the source

The source needs no extra package. Enable it, then add #[Auditable] to the controller class or to one method:

config/packages/symfonycorp_audit_log.yaml
symfonycorp_audit_log:
    sources:
        http_kernel: true
src/Controller/BookController.php
use SymfonyCorp\AuditLog\Attribute\Auditable;

class BookController
{
    #[Auditable]
    public function delete(): Response {} // only this action is recorded
}

The entry

Each access gives one ACCESS entry. A request that fails once its controller is resolved (an exception, a denied #[IsGranted]) is recorded too. A request rejected earlier, for example by access_control in the firewall, gives no entry. The context has these keys:

Masked URL parameters

URLs can contain personal data, such as a reset token or an email. The bundle masks the route parameters token, password and email by default, in route_params and in path. Only the listed parameters are masked: a {resetToken} parameter is stored as it is.

Set your own list with a transformation for each parameter. Your list replaces the default one, and {} masks nothing:

config/packages/symfonycorp_audit_log.yaml
symfonycorp_audit_log:
    sources:
        http_kernel:
            sensitive_params:
                token: hidden
                email: keyed_hash

Sub-requests

Sub-requests (render(controller(...)), forward(), inline ESI fragments) are not recorded by default. Set sub_requests: true to record them:

config/packages/symfonycorp_audit_log.yaml
symfonycorp_audit_log:
    sources:
        http_kernel:
            sub_requests: true