Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: add configurable Horizon dashboard admin access

Selim Salihovic2ff0233f478a
diff --git a/.env.development.example b/.env.development.example
index 594b89201e..8537a9b99a 100644
--- a/.env.development.example
+++ b/.env.development.example
@@ -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
+
# Enable Laravel Nightwatch monitoring
NIGHTWATCH_ENABLED=false
NIGHTWATCH_TOKEN=
diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php
index 0caa3a3a93..037636496b 100644
--- a/app/Providers/HorizonServiceProvider.php
+++ b/app/Providers/HorizonServiceProvider.php
@@ -55,9 +55,18 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
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);
});
}
}