3 namespace BookStack\Http\Middleware;
5 use BookStack\Util\CspService;
7 use Illuminate\Http\Request;
14 protected $cspService;
16 public function __construct(CspService $cspService)
18 $this->cspService = $cspService;
22 * Handle an incoming request.
24 * @param Request $request
25 * @param Closure $next
29 public function handle($request, Closure $next)
31 view()->share('cspNonce', $this->cspService->getNonce());
32 if ($this->cspService->allowedIFrameHostsConfigured()) {
33 config()->set('session.same_site', 'none');
36 $response = $next($request);
38 $this->cspService->setFrameAncestors($response);
39 $this->cspService->setScriptSrc($response);
40 $this->cspService->setObjectSrc($response);
41 $this->cspService->setBaseUri($response);