Create Authentication Provider instance.
@param \Silex\Application $app
@param UserProviderInterface $userProvider
@param string $providerKey
@return SimpleAuthenticationProvider
346150
public function createAuthenticationProvider(\Silex\Application $app,
                                                 UserProviderInterface $userProvider,
                                                 $providerKey)
    {
        return parent::createAuthenticationProvider($app, $userProvider, $providerKey);
    }
755961
public function createAuthorizerApplication($authorizerCorpId, $permanentCode)
    {
        $this->fetch('authorization')
             ->setAuthorizerCorpId($authorizerCorpId)
             ->setAuthorizerPermanentCode($permanentCode);

        $application = $this->fetch('app');
        $application['access_token'] = $this->fetch('authorizer_access_token');
        $application['oauth'] = $this->fetch('oauth');

        return $application;
    }
1338414
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
    {
        // if the user hit a secure page and start() was called, this was
        // the URL they were on, and probably where you want to redirect to
        $targetPath = $request->getSession()->get('_security.'.$providerKey.'.target_path');

        if (!$targetPath) {
            $targetPath = $this->getDefaultSuccessRedirectUrl();
        }

        return new RedirectResponse($targetPath);
    }
450999
public function checkCode(UserInterface $user, $code)
    {
        return $this->authenticator->checkCode($user->getTwoStepVerificationCode(), $code);
    }
610291
public function createUserProvider($provider)
    {
        $config = $this->app['config']["auth.providers.{$provider}"];

        // Retrieve the driver from configuration.
        $driver = $config['driver'];

        if (isset($this->customProviderCreators[$driver])) {
            $callback = $this->customProviderCreators[$driver];

            return call_user_func($callback, $this->app, $config);
        }

        switch ($driver) {
            case 'database':
                return $this->createDatabaseProvider($config);

            case 'extended':
                return $this->createExtendedProvider($config);

            default:
                break;
        }

        throw new InvalidArgumentException("Authentication user provider [{$driver}] is not defined.");
    }
211663
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
    {
        return $this->authenticateApiKeyToken($token, $userProvider, $providerKey);
    }
129622
public function registerProvider($key, LocationProviderInterface $provider)
    {
        if (!$this->hasProvider($key)) {
            $this->providers[$key] = $provider;
        }
    }
980987
public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null)
    {
        $this->migrateSession($request, $token, $providerKey);
        $this->tokenStorage->setToken($token);

        if (null !== $this->dispatcher) {
            $loginEvent = new InteractiveLoginEvent($request, $token);
            $this->dispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN);
        }
    }
377010
protected function linkProvider($user_id, $provider, $provider_id, $access_token)
	{
		$user_provider = new Provider;
		$user_provider->user_id = $user_id;
		$user_provider->provider = strtolower($provider);
		$user_provider->provider_id = $provider_id;
		$user_provider->access_token = $access_token;
		$user_provider->save();
		
		return $user_provider;
	}
929554
public function auth($provider_name, &$profile = null) {
        $identifier = null;
        try {
            $provider = $this->hybrid_auth->authenticate($provider_name);
            $userProfile = $provider->getUserProfile();
            $identifier = $userProfile->identifier;
            $profile = $userProfile;
        } catch (\Exception $e) {
            dd($e->getMessage());
        }

        return $identifier;
    }
486284
public function provider(ProviderRequest $providerRequest)
    {
      // Extract SimplePay user from request
      $user = $providerRequest->getUser();

      // Create request
      $request = new StdClass();
      $request->User = new StdClass();
      $request->User->Uuid = $user->getUuid()->getValue();
      $request->User->Hash = $user->getHash();

      /*$request = new StdClass();
       $request->Auth = new StdClass();
       $request->Auth->Uuid
       $request->Auth->Method
       $request->Auth->Signature
       $request->Auth->Token
       $request->Auth->Timestamp
       $request->Auth->Nonce
       $request->Auth->Version*/

      // Check type
      if($providerRequest->hasType())
        $request->Type = $providerRequest->getType();

      // Send request
      $response = $this->getSoapClient()->provider($request);

      // Create a new ProviderResponse
      $providerResponse = new ProviderResponse();

      if(!is_array($response->Provider))
        $response->Provider = array($response->Provider);

      foreach($response->Provider as $provider)
      {
        // Extract values from reponse
        $uuid = $provider->Uuid;
        $name = $provider->Name;
        $type = $provider->Type;

        $uuid = new Uuid($uuid);

        // Create a new Provider
        $provider = new Provider($uuid, $name, $type);

        // Add bank to response
        $providerResponse->addProvider($provider);
      }

      return $providerResponse;
    }
262338
private function createAuthorization($userId, $instanceId)
    {
        $apiAll = $this->getNavitiaApiAllId();
        $this->call($this->tyrUrl . '/' . $this->version . '/users/' . $userId . '/authorizations/?api_id=' . $apiAll->id . '&instance_id=' . $instanceId, 'POST');

        return true;
    }
1004863
public function verifyStartAuthorization($deliveryId, User $user)
    {
        foreach ($this->getProviders() as $provider) {
            $provider->verifyStartAuthorization($deliveryId, $user);
        }
    }
384143
public function addAuthenticationFactory(AuthenticationFactoryInterface $authFactory,
                                             UserProviderInterface $userProvider)
    {
        $id = $authFactory->getId();

        $this->authFactories[$id] = array(
            'factory' => $authFactory,
            'userProvider' => $userProvider,
        );

        $this->userProviders[] = $userProvider;

        if ($this->provider) {
            $this->registerAuthenticationFactory($this->provider->getApp(), $id, $authFactory, $userProvider);
        }

        return $this;
    }
149292
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
    {
        $token = $this->userProvider->getDecodedToken($credentials['jwt']);
        $clientKey = $token->iss;

        if (!$clientKey) {
            throw new AuthenticationException(
                \sprintf('API Key "%s" does not exist.', $credentials['jwt'])
            );
        }

        /** @var TenantInterface|UserInterface $user */
        $user = $this->userProvider->loadUserByUsername($clientKey);
        if (\property_exists($token, 'sub')) {
            // for some reasons, when webhooks are called - field sub is undefined
            $user->setUsername($token->sub);
        }

        return $user;
    }
1003997
public static function enable2FA($userUid, $authenticationKey, $verificationCode) {
        $request = array(
            'authenticationKey' => $authenticationKey,
            'verificationCode' => $verificationCode
        );
        return Pencepay_Util_HttpClient::postArray("/user/$userUid/tfa_enable", $request);
    }
772144
public static function getFromIdentityProvider(Provider $identityProvider)
    {
        // Have the identity provider authenticate the current identity.
        $identityProvider->authenticate();
        // The identity is valid according to the provider, so authentication is
        // passed.
        $userId = $identityProvider->getUserId();
        // Check for authorisation.
        try {
            Logger::get()->debug(sprintf(
                'Checking OpenID user %s...',
                $userId
            ));
            $user = Users::getInstance()->findEntity($userId);
            // The user is valid according to our records. Keep it in the session.
            $user->authenticate($identityProvider);
        } catch (NotFoundException $exception) {
            Logger::get()->warning(sprintf(
                'OpenID user %s is not known.',
                $userId
            ));
            throw new NotAuthorisedException(
                'OpenID user is not authorised.'
            );
        }

        return $user;
    }