我想防止我的网站受到clickJacking攻击。在哪个文件中以及在哪里设置X帧选项以防止clickJacking攻击.
发布于 2020-05-28 07:44:29
你有两种方法:
)中。
add_header X-Frame-Options "SAMEORIGIN";Illuminate\Http\Middleware\FrameGuard。<?php
namespace Illuminate\Http\Middleware;
use Closure;
class FrameGuard
{
/**
* Handle the given request and get the response.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
return $response;
}
}发布于 2022-07-06 13:09:50
要解决所有路线上的问题:
将FrameGuard::class,添加到app/http/Kernel.php中的protected $middleware上
默认情况下,FrameGuard.php设置为"SAMEORIGIN",但您可以使用"DENY"或"ALLOW-FROM uri" (根据您的需要)更改以下行的第二个参数:
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
https://stackoverflow.com/questions/62059386
复制相似问题