Restrict Activity Log Access to Admins Only Without Blocking Panel for Other Users #138
Unanswered
MasterAdmin2
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, first of all, thank you for this awesome logger plugin!
I'm using Spatie Roles (via spatie/laravel-permission) in my Filament app, and I want to achieve the following behavior:
✅ Admin users (with role admin) should have full access to the Activity Log (sidebar + data table).
🚫 Non-admin users should still be able to access the Filament panel (dashboard, other resources), but:
Should not see the "Activity Log" sidebar menu
Should be denied access (403) if they try to access the logger route manually
Hiding the sidebar with navigationItems() + ->visible(...):
ActivityResource::navigationItems([ NavigationItem::make('Activity Log')->visible(fn () => auth()->user()?->hasRole('admin')), ]);
Using Filament::serving() hook to remove navigation for non-admins:
Filament::serving(function () { if (!auth()->user()?->hasRole('admin')) { // remove nav } });
Wrapping the /admin/activity-logs route with custom middleware (auth + role check):
Route::middleware(['auth', 'role:admin'])->get('/admin/activity-logs', ...);
Ideal Feature Request / Solution
Would it be possible to support role-based access control for the logger resource, for example by:
Exposing a canAccess() or shouldRegisterNavigation() method on the internal ActivityResource, or
Allowing us to publish the ActivityResource file to our app so we can override it like a normal Filament resource
Or making it easier to hook into the logger route protection via middleware config
I love this plugin and it’s working great for admins — just need a clean way to limit access to logger only for admins without affecting other users' ability to use the rest of the panel.
Thanks again!
Beta Was this translation helpful? Give feedback.
All reactions