@DI\Observe("render_external_authentication_button", priority=1)

@param RenderAuthenticationButtonEvent $event

@return string
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);
        }
    }
345618
private function renderPasteIntoButton(GetPasteButtonEvent $event)
    {
        if (null !== ($value = $event->getHtmlPasteInto())) {
            return $value;
        }

        $label = $this->translate('pasteinto.0');
        if ($event->isPasteIntoDisabled()) {
            return $this->renderImageAsHtml('pasteinto_.svg', $label, 'class="blink"');
        }

        if ('pasteinto.1' !== ($opDesc = $this->translate('pasteinto.1'))) {
            $title = \sprintf($opDesc, $event->getModel()->getId());
        } else {
            $title = \sprintf('%s id %s', $label, $event->getModel()->getId());
        }

        return \sprintf(
            ' <a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
            $event->getHrefInto(),
            StringUtil::specialchars($title),
            $this->renderImageAsHtml('pasteinto.svg', $label, 'class="blink"')
        );
    }
1343445
public function onBeforeSend(Event $event)
    {
        /** @var $request Request */
        $request = $event['request'];

        $id = $this->signatureCredentials->getMacId();
        $ts = $this->timeProvider->getCurrentTime()->getTimestamp();
        $nonce = $this->randomProvider->generateStringForRanges($this->nonceLength, self::$characterRanges);
        $ext = $this->extensionProvider->getExtensionParameters($request, $this->signatureCredentials, $ts, $nonce);
        $ext = http_build_query($ext, null, '&');
        $mac = $this->algorithmManager->generateMac($request, $this->signatureCredentials, $ts, $nonce, $ext);

        $params = array(
            'id' => $id,
            'ts' => $ts,
            'nonce' => $nonce,
            'ext' => $ext,
            'mac' => $mac,
        );

        $list = array();
        foreach ($params as $key => $value) {
            $list[] = $key . '="' . $value . '"';
        }
        $header = 'MAC ' . implode(', ', $list);

        $request->setHeader('Authorization', $header);
    }
1307214
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
    {
        /*
         * Avoid OAuth Authorization attack as described at
         * http://software-security.sans.org/blog/2011/03/07/oauth-authorization-attacks-secure-implementation.
         */
        if ($this->session->has('_security.target_path')) {
            if (false !== strpos($this->session->get('_security.target_path'), $this->generateUrl('fos_oauth_server_authorize'))) {
                $this->session->set('_fos_oauth_server.ensure_logout', true);
            }
        }

    }
1277935
public function authorizeActionsOnControllerArguments(FilterControllerArgumentsEvent $event): void
    {
        foreach ($event->getArguments() as $argument) {
            if ($argument instanceof AuthorizeActionInterface) {
                $this->authorizationChecker->verify($argument);
            }
        }
    }
429346
public function onExternalAuthenticationMenuConfigure(ConfigureMenuEvent $event)
    {
        $name = $this->translator->trans('external_user_group_parameters', [], 'claro_external_user_group');
        $menu = $event->getMenu();
        $menu->addChild(
            $name,
            [
                'route' => 'claro_admin_external_sync_config_index',
            ]
        )->setExtra('name', $name);

        return $menu;
    }
397885
protected function getEventLogInfo(Event $event, $eventName)
    {
        if ($event instanceof EmbeddedEventResolverInterface) {
            return $event->getEventLogInfo($eventName);
        }

        if (null === $eventResolver = $this->getResolver($eventName)) {
            return null;
        }

        return $eventResolver->getEventLogInfo($event, $eventName);
    }
1147191
def begin_external_authentication(request)
      # We don't have an email domain to work from.
      # Instead, we'll call each engine's authenticate_external method.
      # If one of them returns a user, then we return that value and skip further processing.
      auth_engines.each do |dom,engine|
        unless engine.nil?
          url = engine.begin_external_authentication(request)
          return url unless url.blank?
        end
      end
      nil
    end
701065
public function render($identifier)
    {
        return (isset($this->authenticationProviderSettings[$identifier]['label']) ? $this->authenticationProviderSettings[$identifier]['label'] : $identifier);
    }
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) {
            }
        }
    }
1158571
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        // Ignore sub-requests, including fragments.
        if (!$this->isMasterRequest($request, $event->getRequestType())) {
            return;
        }

        $siteAccess = $request->attributes->get('siteaccess');
        if (!$siteAccess instanceof SiteAccess) {
            return;
        }

        $token = $this->tokenStorage->getToken();
        if ($token === null) {
            return;
        }

        if (
            // Leave access to login route, so that user can attempt re-authentication.
            $request->attributes->get('_route') !== 'login'
            && !$this->hasAccess($siteAccess, $token->getUsername())
        ) {
            throw new UnauthorizedSiteAccessException($siteAccess, $token->getUsername());
        }
    }
973912
public function authenticate(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        try {
            $this->loginManager->logInUser($this->firewallName, $event->getUser(), $event->getResponse());

            $dispatcher->dispatch(Events::SECURITY_IMPLICIT_LOGIN, new UserEvent($event->getUser(), $event->getRequest()));
        } catch (AccountStatusException $e) {
            // We simply do not authenticate users which do not pass the user
            // checker (not enabled, expired, etc.).
        }
    }
903102
public static function signup_user_parameters() {
        return new external_function_parameters(
            array(
                'username' => new external_value(core_user::get_property_type('username'), 'Username'),
                'password' => new external_value(core_user::get_property_type('password'), 'Plain text password'),
                'firstname' => new external_value(core_user::get_property_type('firstname'), 'The first name(s) of the user'),
                'lastname' => new external_value(core_user::get_property_type('lastname'), 'The family name of the user'),
                'email' => new external_value(core_user::get_property_type('email'), 'A valid and unique email address'),
                'city' => new external_value(core_user::get_property_type('city'), 'Home city of the user', VALUE_DEFAULT, ''),
                'country' => new external_value(core_user::get_property_type('country'), 'Home country code', VALUE_DEFAULT, ''),
                'recaptchachallengehash' => new external_value(PARAM_RAW, 'Recaptcha challenge hash', VALUE_DEFAULT, ''),
                'recaptcharesponse' => new external_value(PARAM_NOTAGS, 'Recaptcha response', VALUE_DEFAULT, ''),
                'customprofilefields' => new external_multiple_structure(
                    new external_single_structure(
                        array(
                            'type'  => new external_value(PARAM_ALPHANUMEXT, 'The type of the custom field'),
                            'name'  => new external_value(PARAM_ALPHANUMEXT, 'The name of the custom field'),
                            'value' => new external_value(PARAM_RAW, 'Custom field value, can be an encoded json if required')
                        )
                    ), 'User custom fields (also known as user profile fields)', VALUE_DEFAULT, array()
                ),
                'redirect' => new external_value(PARAM_LOCALURL, 'Redirect the user to this site url after confirmation.',
                                                    VALUE_DEFAULT, ''),
            )
        );
    }
415519
protected function renderExternal(Asset $asset, $group)
    {
        return '<!-- asset external'.$this->renderAttributes(['href' => $asset->uri()], $asset->attributes()).' -->';
    }
743295
public function authorizeRequest(Event $event)
    {
        /* @var \Guzzle\Service\Command\CommandInterface $command */
        $command = $event['command'];

        $request = $command->getRequest();
        $request->setAuth($this->apiKey);
    }
65798
protected function getExternalIdentifierFromRecordData(array $data)
    {
        $externalIdentifier = Arrays::getValueByPath($data, $this->externalIdentifierDataKey);
        if ($externalIdentifier === null) {
            throw new \Exception('Could not determine external identifier from record data. See ' . self::class . ' for more information.', 1462968317292);
        }
        return (string)$externalIdentifier;
    }
330744
public function onCoreException(GetResponseForExceptionEvent $event)
	{
	    $exception = $event->getException();
	    $request = $event->getRequest();

    	if ($request->isXmlHttpRequest()) {
    		$msg = "";
    		if($exception instanceof AccessDeniedException ) {
    			$msg = "User Not Authenticated";
    		} elseif($exception instanceof AuthenticationCredentialsNotFoundException) {
    			$msg = "User Not Allowed";
    		} elseif($exception instanceof AuthenticationException) {
    			// Change this
    			$msg = "User Not Authenticated";
    		}

    		if($msg) {
    			$responseData = array('status' => 403, 'reason' => $msg);
    			$response = new JsonResponse();
    			$response->setData($responseData);
    			$response->setStatusCode($responseData['status']);
    			$event->setResponse($response);
    		}
	    }
	}