b76566a2d6
Build Docker Image / build-frontend (push) Successful in 42s
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Co-authored-by: nurafrinaalimi16 <nurafrinaalimi16@gmail.com> Reviewed-on: #28
33 lines
942 B
PHP
33 lines
942 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
|
|
class LogViewerPassword
|
|
{
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$passwordHash = config('logviewer.password');
|
|
|
|
if (!is_string($passwordHash) || $passwordHash === '') {
|
|
return response('Akses log belum dikonfigurasi.', 503)
|
|
->header('Cache-Control', 'no-store');
|
|
}
|
|
|
|
$provided = $request->getPassword();
|
|
if ($request->getUser() !== 'logviewer' || !is_string($provided) ||
|
|
!password_verify($provided, $passwordHash)) {
|
|
return response('Kata laluan diperlukan untuk mengakses log.', 401, [
|
|
'WWW-Authenticate' => 'Basic realm="Log Viewer", charset="UTF-8"',
|
|
'Cache-Control' => 'no-store',
|
|
]);
|
|
}
|
|
|
|
$response = $next($request);
|
|
$response->headers->set('Cache-Control', 'no-store');
|
|
|
|
return $response;
|
|
}
|
|
}
|