summaryrefslogtreecommitdiff
path: root/app/Middleware/BootstrapMiddleware.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-15 18:31:47 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-15 18:31:47 -0400
commit67b836164997527b91452b19adbcb8aa3c5decf1 (patch)
treeb5876d311912e97b0592c7e208639f7b52813a75 /app/Middleware/BootstrapMiddleware.php
parent108e867605dbc7ece4cbcbecc89a674e9c154a9b (diff)
Refactoring: added controlled middleware and changed response class
Diffstat (limited to 'app/Middleware/BootstrapMiddleware.php')
-rw-r--r--app/Middleware/BootstrapMiddleware.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/Middleware/BootstrapMiddleware.php b/app/Middleware/BootstrapMiddleware.php
new file mode 100644
index 00000000..c9de1de9
--- /dev/null
+++ b/app/Middleware/BootstrapMiddleware.php
@@ -0,0 +1,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->router->getAction() !== 'readonly') {
+ $this->response->withXframe();
+ }
+
+ if (ENABLE_HSTS) {
+ $this->response->withStrictTransportSecurity();
+ }
+ }
+}