summaryrefslogtreecommitdiff
path: root/app/Middleware/BootstrapMiddleware.php
blob: 727f600ce2723b3fee9cbae9d62943e8ca928f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

namespace Kanboard\Middleware;

use Kanboard\Core\Controller\BaseMiddleware;

/**
 * Class BootstrapMiddleware
 *
 * @package Kanboard\Middleware
 * @author  Frederic Guillot
 */
class BootstrapMiddleware extends BaseMiddleware
{
    /**
     * Execute middleware
     */
    public function execute()
    {
        $this->sessionManager->open();
        $this->dispatcher->dispatch('app.bootstrap');
        $this->sendHeaders();
        $this->next();
    }

    /**
     * Send HTTP headers
     *
     * @access private
     */
    private function sendHeaders()
    {
        $this->response->withContentSecurityPolicy($this->container['cspRules']);
        $this->response->withSecurityHeaders();

        if (ENABLE_XFRAME) {
            $this->response->withXframe();
        }

        if (ENABLE_HSTS) {
            $this->response->withStrictTransportSecurity();
        }
    }
}