enricoluigi

Application.php CSRF DISABLED

May 28th, 2020
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. public function middleware($middlewareQueue)
  2.     {
  3.         $securityHeaders = new SecurityHeadersMiddleware();
  4.         $securityHeaders
  5.             ->setCrossDomainPolicy()
  6.             ->setReferrerPolicy()
  7.             ->setXFrameOptions()
  8.             ->setXssProtection()
  9.             ->noOpen()
  10.             ->noSniff();
  11.            
  12.         $middlewareQueue
  13.             // Catch any exceptions in the lower layers,
  14.             // and make an error page/response
  15.             ->add(ErrorHandlerMiddleware::class)
  16.  
  17.             // Handle plugin/theme assets like CakePHP normally does.
  18.             ->add(AssetMiddleware::class)
  19.  
  20.             // Add routing middleware.
  21.             // Routes collection cache enabled by default, to disable route caching
  22.             // pass null as cacheConfig, example: `new RoutingMiddleware($this)`
  23.             // you might want to disable this cache in case your routing is extremely simple
  24.             ->add(new RoutingMiddleware($this, '_cake_routes_'))
  25.  
  26.             // Add csrf middleware.
  27.             // ->add(new CsrfProtectionMiddleware([
  28.             //     'httpOnly' => true
  29.             // ]))
  30.             ->add($securityHeaders);
  31.  
  32.         return $middlewareQueue;
  33.     }
Add Comment
Please, Sign In to add comment