Logs an authentication event.

@param AuthEvent $event

@return void
961101
public function auth(AuthEvent $event)
    {
        if (isset($this->logger)) {
            $operation = get_class($event);

            $connection = $event->getConnection();

            $message = "LDAP ({$connection->getHost()})"
                . " - Connection: {$connection->getName()}"
                . " - Operation: {$operation}"
                . " - Username: {$event->getUsername()}";

            $result = null;
            $type = 'info';

            if (is_a($event, Failed::class)) {
                $type = 'warning';
                $result = " - Reason: {$connection->getLastError()}";
            }
            
            $this->logger->$type($message.$result);
        }
    }
271542
protected function fireLoginEvent($user, $remember = false)
    {
        if (isset($this->events)) {
            $this->events->fire('auth.login', [$user, $remember]);
        }
    }
85254
public function logActivity($event)
    {
        // if cronjob / no user
        if (user()->id <= 0) {
            return;
        }

        // log adjustment
        LogAdminActivity::create([
            'subject_id'   => $this->id,
            'subject_type' => get_class($this),
            'name'         => $this->getActivityName($this, $event),
            'before'       => $this->before,
            'after'        => $this->after,
            'user_id'      => user()->id,
        ]);
    }
1053455
public function onGetUser(GetUserForTokenEvent $event)
    {
        $userProvider = $event->getUserProvider();

        if (!$userProvider instanceof OAuthUserProviderInterface) {
            return;
        }

        $token = $event->getToken();

        if ($user = $userProvider->loadUserByOAuthCredentials($token)) {
            $token->setUser($user);
        }
    }
401975
public function onKernelRequestAuthToken($event)
  {
    if (!$event->isMasterRequest()) return;
    
    // Bearer jwt
    $auth = $event->getRequest()->getHeaderLine('Authorization');
    if (!$auth) return;
    
    $authParts = explode(' ',$auth);
    $jwt = $authParts[count($authParts)-1];
    
    if (!$jwt) return;

    $jwtPayload = $this->jwtCoder->decode($jwt);
    
    $authToken = new AuthToken($jwtPayload['username'],$jwtPayload['roles']);
    
    $event->getRequest()->setAttribute('authToken',$authToken);
  }
962671
public function afterLogout(Event $event)
    {
        $this->_controller()->Cookie->delete('Jwt');
        $this->_controller()->Cookie->delete('CookieAuth');
    }
187289
public function onAuthenticationSuccess(AuthenticationEvent $event)
    {
        $loggedUser = $event
            ->getAuthenticationToken()
            ->getUser();

        $cart = $this
            ->cartWrapper
            ->get();

        if (
            ($loggedUser instanceof CustomerInterface) &&
            ($cart instanceof CartInterface && $cart->getId())
        ) {
            /*
             * We assume that a cart with an ID is
             * not a pristine entity coming from a
             * factory method. (i.e. has already been
             * flushed)
             */
            $cart->setCustomer($loggedUser);

            $this->cartManager->flush($cart);
        }
    }
557111
public function onRenderButton(RenderAuthenticationButtonEvent $event)
    {
        $services = $this->oauthManager->getActiveServices();
        $buttons = [];

        foreach ($services as $service) {
            $config = $this->oauthManager->getConfiguration($service);
            $buttons[] = ['service' => $service, 'display_name' => $config->getDisplayName()];
        }

        if (count($services) > 0) {
            $content = $this->templating->render(
                'ClarolineAuthenticationBundle:oauth:buttons.html.twig',
                ['buttons' => $buttons]
            );

            $event->addContent($content);
        }
    }
982712
public function footprint(Event $event)
    {
        if (!$this->_listener) {
            $this->_listener = new FootprintListener($this->_getCurrentUser());
        }

        if ($event->getName() === 'Auth.afterIdentify') {
            $this->_listener->setUser($this->_getCurrentUser($event->getData(0)));

            return;
        }

        $event->getSubject()->getEventManager()->on($this->_listener);
    }
278533
public function handle(Login $event)
    {
        $model = snake_case(class_basename($event->user));
        $data = [
            'ip'       => request()->ip(),
            'ua'       => request()->header('User-Agent'),
            'remember' => $event->remember,
        ];
        $event->user->log("{$model}.login", $data);
    }
124728
public function httpPassword(Event $event)
    {
        $event['request']->setHeader('Authorization', sprintf('Basic %s', base64_encode($this->auth['username'] . ':' . $this->auth['password'])));
    }
1006784
public function add_events()
    {

        // Internal Authentication Events
        $this->app->events->listen(LoginEvent::class, Login::class);
        $this->app->events->listen(LogoutEvent::class, Logout::class);
        $this->app->events->listen(Attempting::class, Attempt::class);

        // Custom Events
        $this->app->events->listen('security.log', SecLog::class);
    }
913931
public function urlSecret(Event $event)
    {
        $query = $event['request']->getQuery();

        $query->set('client_id', $this->auth['client_id']);
        $query->set('client_secret', $this->auth['client_secret']);
    }
1304994
public function onRequestCreate(Event $event)
    {
        $client = $event['client'];
        $token = $client->getToken();
        
        $event['request']->setHeader('X-Auth-Token', $token);
    }
743295
public function authorizeRequest(Event $event)
    {
        /* @var \Guzzle\Service\Command\CommandInterface $command */
        $command = $event['command'];

        $request = $command->getRequest();
        $request->setAuth($this->apiKey);
    }
824931
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
    {
        /* @var BaseUser $user */
        $user = $event->getAuthenticationToken()->getUser();

        if ($user instanceof UserInterface) {
            $this->logger->info($user . ' successfully logged in to the cms');
            $this->versionChecker->periodicallyCheck();
        }
    }
448094
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $requestToken = $this->getToken(
            $request->headers->get($this->options['header_name'], null)
        );

        if (!empty($requestToken)) {
            try {
                $decoded = $this->encode->decode($requestToken);
                $user = null;
                if (isset($decoded->{$this->options['username_claim']})) {
                    $user = $decoded->{$this->options['username_claim']};
                }

                $token = new JWTToken(
                    $user,
                    $requestToken,
                    $this->providerKey
                );

                $authToken = $this->authenticationManager->authenticate($token);
                $this->securityContext->setToken($authToken);

            } catch (HttpEncodingException $e) {
            } catch (\UnexpectedValueException $e) {
            }
        }
    }