Render proxy authentication exception as 407 response

This commit is contained in:
Bubka 2022-05-19 15:47:34 +02:00
parent 60787d9328
commit 9deb821d53

View File

@ -59,5 +59,16 @@ class Handler extends ExceptionHandler
return response()->json([ return response()->json([
'message' => $exception->getMessage()], 400); 'message' => $exception->getMessage()], 400);
}); });
$this->renderable(function (\Illuminate\Auth\AuthenticationException $exception, $request) {
if ($exception->guards() === ['reverse-proxy-guard']) {
return response()->json([
'message' => $exception->getMessage()], 407);
}
else {
return response()->json([
'message' => $exception->getMessage()], $exception->getCode());
}
});
} }
} }