- dev/betrieb/deploy.sh: Deploy nur per Tag, mit --seed (Seeder im Wartungsmodus) und --initial (Vorschau/Live einmalig an Ort und Stelle auf Git umstellen) - dev/betrieb/vorschau-auffrischen.sh: Live-DB und Live-Medien in die Vorschau (Generalprobe) - InteriorReleaseSeeder: alle Inhaltsschritte des Relaunchs in einem Lauf, idempotent; Displays, Playlists und Mediathek bleiben unberührt - DisplayInteriorBrandingSeeder überschreibt keinen inzwischen gepflegten Claim mehr - Monitoring: GlitchTip (Server + Browser), /health mit Token, Scheduler-Herzschlag, Alarme per Mail und ntfy, Version in about und /health - public/build versioniert; .gitignore: macOS-Muster Icon traf resources/views/flux/icon/ - Runbook: dev/betrieb/README.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class BasicAuthMiddleware
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
// Skip Basic Auth für Livewire-Requests komplett
|
|
// Diese sind bereits durch Laravel Session/CSRF geschützt
|
|
$path = $request->path();
|
|
|
|
if (
|
|
str_starts_with($path, 'livewire/') ||
|
|
str_starts_with($path, 'livewire-') ||
|
|
str_contains($path, '/livewire/') ||
|
|
str_contains($path, '/livewire-') ||
|
|
$request->is('livewire/*') ||
|
|
$request->is('livewire-*') ||
|
|
$request->is('*/livewire/*') ||
|
|
$request->is('*/livewire-*')
|
|
) {
|
|
return $next($request);
|
|
}
|
|
|
|
// Skip Basic Auth für den Health-Check: Uptime Kuma schickt seinen eigenen
|
|
// Authorization-Header (Bearer-Token), /health prüft ihn selbst.
|
|
if ($path === 'health' || $path === 'up') {
|
|
return $next($request);
|
|
}
|
|
|
|
// Skip Basic Auth für Flux UI Assets (flux.js, flux.min.js, editor.js, etc.)
|
|
if (str_starts_with($path, 'flux/')) {
|
|
return $next($request);
|
|
}
|
|
|
|
// Skip Basic Auth für Display-API, Cabinet-Tablet-API und Short-Links (öffentlicher Zugriff für Display-Seiten)
|
|
// Skip Basic Auth für Display-API, Cabinet-Tablet-API und Short-Links (öffentlicher Zugriff für Display-Seiten)
|
|
if (
|
|
$request->is('api/display/*') || $request->is('api/cabinet-tablet/*') || $request->is('_cabinet/*') ||
|
|
str_contains($request->url(), 'portal.b2in.test') || str_contains($request->url(), 'portal.b2in.eu') ||
|
|
str_contains($request->url(), 'b2in.test') || str_contains($request->url(), 'b2in.eu')
|
|
|
|
) {
|
|
return $next($request);
|
|
}
|
|
|
|
// Credentials from .env file
|
|
$user = config('auth.basic.user');
|
|
$pass = config('auth.basic.password');
|
|
|
|
if ($request->getUser() != $user || $request->getPassword() != $pass) {
|
|
return response('Unauthorized.', 401, ['WWW-Authenticate' => 'Basic']);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|