40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
|
|
class AddXHeader
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$response = $next($request);
|
|
|
|
// Check if we should add header
|
|
if (method_exists($response, 'header')) {
|
|
$response->header('X-Akaunting', 'Online Accounting Software');
|
|
$response->header('X-Content-Type-Options', 'nosniff');
|
|
$response->header('X-Frame-Options', 'SAMEORIGIN');
|
|
if (! $response->headers->has('Referrer-Policy')) {
|
|
$response->header('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
}
|
|
$response->header('X-XSS-Protection', '0');
|
|
$response->header('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');
|
|
if ($request->routeIs('login.dingtalk', 'login.dingtalk.callback', 'business.store-account-passwords.reveal', 'business.store-account-passwords.reveal-visible-page')) {
|
|
$response->header('Cache-Control', 'no-store');
|
|
$response->header('Pragma', 'no-cache');
|
|
$response->header('Referrer-Policy', 'no-referrer');
|
|
}
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
}
|