From 67b836164997527b91452b19adbcb8aa3c5decf1 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 15 May 2016 18:31:47 -0400 Subject: Refactoring: added controlled middleware and changed response class --- app/Middleware/BootstrapMiddleware.php | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/Middleware/BootstrapMiddleware.php (limited to 'app/Middleware/BootstrapMiddleware.php') 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 @@ +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(); + } + } +} -- cgit v1.2.3