EasyAdmin viewer
With easycorp/easyadmin-bundle and a readable output, read the entries in your EasyAdmin dashboard.
Overview
The list has filters on source, action and dates. Each entry has a detail page with its context and an integrity badge.
Requirements
The pages need SecurityBundle and a firewall that covers their path. Without SecurityBundle, the pages throw an error.
Add the viewer
Import the routes under the path of your dashboard:
symfonycorp_audit_log_easyadmin:
resource: '@AuditLogBundle/config/routes/easyadmin.php'
prefix: /admin/audit-log
# With more than one dashboard, select one:
# defaults:
# dashboardControllerFqcn: App\Controller\Admin\DashboardControllerAdd a menu item. setPermission() hides the item from the users without ROLE_AUDIT_LOG_VIEWER:
// In your DashboardController::configureMenuItems()
yield MenuItem::linkToRoute('Audit Log', 'fa fa-history', 'symfonycorp_audit_log_easyadmin_index')
->setPermission('ROLE_AUDIT_LOG_VIEWER');With more than one readable output, select one with ?output=<name> in the URL.
The viewer records each read in an entry with the audit_log source: one READ entry for each page of the list and for each detail page. See Commands.
Give the role
Give ROLE_AUDIT_LOG_VIEWER only to the users who must read the entries. The bundle does not give this role to anyone. ROLE_ADMIN does not include it. Add it to a role of your own in the role hierarchy:
security:
role_hierarchy:
ROLE_AUDITOR: [ROLE_AUDIT_LOG_VIEWER]Give ROLE_AUDITOR to these users. You can also add it to a role that they already have, for example ROLE_ADMIN: [ROLE_USER, ROLE_AUDITOR] under role_hierarchy.
Access checks
A visitor who is not logged in goes to the entry point of the firewall, for example the login form. A user without the role gets a 403 error. The bundle checks the role on each page, also on the menu item URL /admin?routeName=.... Your access_control rules still apply: with { path: ^/admin, roles: ROLE_ADMIN }, a user needs both roles.
Important - the entries show who did what, with user identifiers and IP addresses. Give the role only to the users who must read them.