states, and pulls data from the authenticated /api/v1/tenant/packages endpoint.
(resources/js/admin/pages/EventFormPage.tsx, resources/js/admin/api.ts)
- Harden tenant-admin auth flow: prevent PKCE state loss, scope out StrictMode double-processing, add SPA
routes for /event-admin/login and /event-admin/logout, and tighten token/session clearing semantics (resources/js/admin/auth/{context,tokens}.tsx, resources/js/admin/pages/{AuthCallbackPage,LogoutPage}.tsx,
resources/js/admin/router.tsx, routes/web.php)
134 lines
4.6 KiB
PHP
134 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\Checkout\CheckoutAssignmentService;
|
|
use App\Services\Checkout\CheckoutPaymentService;
|
|
use App\Services\Checkout\CheckoutSessionService;
|
|
use App\Notifications\UploadPipelineFailed;
|
|
use App\Services\Storage\EventStorageManager;
|
|
use App\Services\Storage\StorageHealthService;
|
|
use App\Services\Security\PhotoSecurityScanner;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Queue\Events\JobFailed;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Inertia\Inertia;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(CheckoutSessionService::class);
|
|
$this->app->singleton(CheckoutAssignmentService::class);
|
|
$this->app->singleton(CheckoutPaymentService::class);
|
|
$this->app->singleton(EventStorageManager::class);
|
|
$this->app->singleton(StorageHealthService::class);
|
|
$this->app->singleton(PhotoSecurityScanner::class);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->app->make(EventStorageManager::class)->registerDynamicDisks();
|
|
|
|
RateLimiter::for('tenant-api', function (Request $request) {
|
|
$tenantId = $request->attributes->get('tenant_id')
|
|
?? $request->user()?->tenant_id
|
|
?? $request->user()?->tenant?->id;
|
|
|
|
$key = $tenantId ? 'tenant:' . $tenantId : ('ip:' . ($request->ip() ?? 'unknown'));
|
|
|
|
return Limit::perMinute(100)->by($key);
|
|
});
|
|
|
|
RateLimiter::for('oauth', function (Request $request) {
|
|
return Limit::perMinute(10)->by('oauth:' . ($request->ip() ?? 'unknown'));
|
|
});
|
|
|
|
Inertia::share('locale', fn () => app()->getLocale());
|
|
Inertia::share('analytics', static function () {
|
|
$config = config('services.matomo');
|
|
|
|
if (!($config['enabled'] ?? false)) {
|
|
return [
|
|
'matomo' => [
|
|
'enabled' => false,
|
|
],
|
|
];
|
|
}
|
|
|
|
return [
|
|
'matomo' => [
|
|
'enabled' => true,
|
|
'url' => rtrim((string) ($config['url'] ?? ''), '/'),
|
|
'siteId' => (string) ($config['site_id'] ?? ''),
|
|
],
|
|
];
|
|
});
|
|
|
|
Inertia::share('security', static function () {
|
|
$request = request();
|
|
|
|
if (! $request) {
|
|
return [
|
|
'csp' => [
|
|
'scriptNonce' => null,
|
|
'styleNonce' => null,
|
|
],
|
|
];
|
|
}
|
|
|
|
return [
|
|
'csp' => [
|
|
'scriptNonce' => $request->attributes->get('csp_script_nonce'),
|
|
'styleNonce' => $request->attributes->get('csp_style_nonce'),
|
|
],
|
|
];
|
|
});
|
|
|
|
if (config('storage-monitor.queue_failure_alerts')) {
|
|
Queue::failing(function (JobFailed $event) {
|
|
$context = [
|
|
'queue' => $event->job->getQueue(),
|
|
'job' => $event->job->resolveName(),
|
|
'exception' => $event->exception->getMessage(),
|
|
];
|
|
|
|
$command = data_get($event->job->payload(), 'data.command');
|
|
|
|
if (is_string($command)) {
|
|
try {
|
|
$instance = @unserialize($command, ['allowed_classes' => true]);
|
|
if (is_object($instance)) {
|
|
foreach (['eventId' => 'event_id', 'photoId' => 'photo_id'] as $property => $label) {
|
|
if (isset($instance->{$property})) {
|
|
$context[$label] = $instance->{$property};
|
|
}
|
|
}
|
|
}
|
|
} catch (\Throwable $e) {
|
|
$context['unserialize_error'] = $e->getMessage();
|
|
}
|
|
}
|
|
|
|
if ($mail = config('storage-monitor.alert_recipients.mail')) {
|
|
Notification::route('mail', $mail)->notify(new UploadPipelineFailed($context));
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($this->app->runningInConsole()) {
|
|
$this->app->register(\App\Providers\Filament\AdminPanelProvider::class);
|
|
}
|
|
}
|
|
}
|