b2in/app/Http/Middleware/AllowPortalFraming.php
Kevin Adametz 69d50eed0f Hotfix: Vorschau im Inhalte-Editor und Seitennavigation der Medienbibliothek
- AllowPortalFraming: frame-ancestors 'self' + Portal statt X-Frame-Options SAMEORIGIN,
  damit portal.b2in.eu die Website im Vorschau-iframe zeigen darf
- Medienbibliothek und Hub-Verwaltung: WithPagination – ohne zeigten die Seitenlinks nach
  dem ersten Livewire-Klick auf den Update-Endpunkt (405); Suche/Filter springen auf Seite 1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 09:36:16 +00:00

36 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Erlaubt die Live-Vorschau im Inhalte-Editor des Portals (09.10.2026).
*
* Der Editor auf portal.b2in.eu zeigt die Website in einem iframe. Der Webserver schickt
* `X-Frame-Options: SAMEORIGIN`, das jede andere Domain ausschließt – also auch das Portal.
* `Content-Security-Policy: frame-ancestors` löst X-Frame-Options ab: Browser werten dann nur
* noch diese Liste aus. Erlaubt sind die eigene Domain und das Portal, alle anderen Seiten
* dürfen die Website weiterhin nicht einbetten.
*/
class AllowPortalFraming
{
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
if ($response->headers->has('Content-Security-Policy')) {
return $response;
}
$portal = rtrim((string) config('domains.domain_portal_url'), '/');
$ancestors = trim("'self' {$portal}");
$response->headers->set('Content-Security-Policy', "frame-ancestors {$ancestors}");
$response->headers->remove('X-Frame-Options');
return $response;
}
}