Skip to content

Commit 8289e11

Browse files
feat: use environment variable for Horizon access control
- Add HORIZON_ALLOWED_EMAILS env variable support - Comma-separated list of emails allowed to access Horizon in production Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9dc04c2 commit 8289e11

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

app/Providers/HorizonServiceProvider.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
1414
public function boot(): void
1515
{
1616
parent::boot();
17-
18-
// Horizon::routeSmsNotificationsTo('15556667777');
19-
// Horizon::routeMailNotificationsTo('example@example.com');
20-
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
2117
}
2218

2319
/**
@@ -28,9 +24,11 @@ public function boot(): void
2824
protected function gate(): void
2925
{
3026
Gate::define('viewHorizon', function ($user = null) {
31-
return in_array(optional($user)->email, [
32-
//
33-
]);
27+
$allowedEmails = array_filter(
28+
array_map('trim', explode(',', config('horizon.allowed_emails', '')))
29+
);
30+
31+
return in_array(optional($user)->email, $allowedEmails);
3432
});
3533
}
3634
}

config/horizon.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030

3131
'domain' => env('HORIZON_DOMAIN'),
3232

33+
/*
34+
|--------------------------------------------------------------------------
35+
| Horizon Allowed Emails
36+
|--------------------------------------------------------------------------
37+
|
38+
| This is a comma-separated list of email addresses that are allowed to
39+
| access Horizon in non-local environments. Leave empty to deny all.
40+
|
41+
*/
42+
43+
'allowed_emails' => env('HORIZON_ALLOWED_EMAILS', ''),
44+
3345
/*
3446
|--------------------------------------------------------------------------
3547
| Horizon Path

0 commit comments

Comments
 (0)