Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ RAY_ENABLED=false
# Enable Laravel Telescope for debugging
TELESCOPE_ENABLED=false

# Laravel Horizon Admin Access
# Comma-separated list of email addresses allowed to access /horizon dashboard
# The root user (User ID 0) always has access
# HORIZON_ALLOWED_EMAILS=admin@example.com,devops@example.com

# Enable Laravel Nightwatch monitoring
NIGHTWATCH_ENABLED=false
NIGHTWATCH_TOKEN=
Expand Down
15 changes: 12 additions & 3 deletions app/Providers/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ protected function gate(): void
Gate::define('viewHorizon', function ($user) {
$root_user = User::find(0);

return in_array($user->email, [
$root_user->email,
]);
// Get additional allowed emails from environment variable
$allowedEmails = array_filter(
array_map('trim', explode(',', env('HORIZON_ALLOWED_EMAILS', '')))
);

// Merge root user email with additional allowed emails
$authorizedEmails = array_merge(
[$root_user->email],
$allowedEmails
);

return in_array($user->email, $authorizedEmails);
});
}
}