/** * Logs calls and results of the authenticate() method of the Authentication Manager * * @after within(F3\FLOW3\Security\Authentication\AuthenticationManagerInterface) && method(.*->authenticate()) * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The current joinpoint * @return mixed The result of the target method if it has not been intercepted * @author Robert Lemke <*****@*****.**> */ public function logManagerAuthenticate(\F3\FLOW3\AOP\JoinPointInterface $joinPoint) { if ($joinPoint->hasException()) { $exception = $joinPoint->getException(); $this->systemLogger->log('Authentication failed: "' . $exception->getMessage() . '" #' . $exception->getCode(), LOG_WARNING); throw $exception; } else { $this->systemLogger->log('Authentication successful.', LOG_INFO); } }
/** * Catches AuthenticationRequired Exceptions and tries to call an authentication entry point, * if available. * * @afterthrowing method(F3\FLOW3\MVC\Dispatcher->dispatch()) && setting(FLOW3.security.enable) * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current joinpoint * @return void * @author Andreas Förthner <*****@*****.**> */ public function forwardAuthenticationRequiredExceptionsToAnAuthenticationEntryPoint(\F3\FLOW3\AOP\JoinPointInterface $joinPoint) { $exception = $joinPoint->getException(); $request = $joinPoint->getMethodArgument('request'); $response = $joinPoint->getMethodArgument('response'); if (!$exception instanceof \F3\FLOW3\Security\Exception\AuthenticationRequiredException) { throw $exception; } $entryPointFound = FALSE; foreach ($this->securityContextHolder->getContext()->getAuthenticationTokens() as $token) { $entryPoint = $token->getAuthenticationEntryPoint(); if ($entryPoint !== NULL && $entryPoint->canForward($request)) { $entryPointFound = TRUE; $entryPoint->startAuthentication($request, $response); } } if ($entryPointFound === FALSE) { throw $exception; } }