errorResponseFactory = $errorResponseFactory; } abstract public function supports(Request $request): ?bool; abstract public function authenticate(Request $request): Passport; public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response { $error = new Error(); $error->message = $exception->getMessageKey(); return $this->errorResponseFactory->create($error,Response::HTTP_FORBIDDEN); } public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey): ?Response { return null; } }