Extend the authentication layer with a custom provider.

@param string          $key
@param object|callable $provider

@return void
480785
public function extend($key, $provider)
    {
        if (is_callable($provider)) {
            $provider = call_user_func($provider, $this->container);
        }

        $this->providers[$key] = $provider;
    }
776475
public function set($key, $token)
    {
        $this->instance->set($key, $token, $this->keyTtl);
    }
862923
private static function saveCredentials($key, $credentials)
    {
        $ttl = ($credentials->expires_in / 60) - 2;

        Core::instance()->cache()->put($key, $credentials->access_token, $ttl);
    }
663072
function (context, authenticationRequest, callback) {
            //
            var authProvider = this.getAuthenticationProviderForRequest(authenticationRequest);

            if (authProvider) {
                flow()
                    .seq("authentication", function (cb) {
                        // authenticate
                        authProvider.authenticate(authenticationRequest, cb);
                    })
                    .seq(function (cb) {
                        // init authentication
                        this.vars.authentication.init(cb);
                    })
                    .exec(function (err, results) {
                        var authentication = results.authentication;
                        if (!err && authentication) {
                            context.user.addAuthentication(authentication);
                        }
                        // return authentication with user id
                        callback(err, authentication);
                    })
            } else {
                callback(AuthenticationError.NO_PROVIDER_FOUND, null);
            }
        }
771479
protected function loadProviders($providers)
	{
		foreach ((array) $providers as $provider) {
			$provider = $this->container->get($provider);

			if (!$provider instanceof ServiceProviderInterface) {
				$providerName = get_class($provider);
				throw new \Exception(
					"$providerName does not implement required \\TitaPHP\\Foundation\\ServiceProviderInterface Interface"
				);
			}

			$provider->register($this);
		}
	}
1099194
public function fromServices($providerName, array $additionalConfigKeys = [])
    {
        $this->providerName = $providerName;
        $this->getConfigFromServicesArray($providerName);

        $this->additionalConfigKeys = $additionalConfigKeys = array_unique($additionalConfigKeys + ['guzzle']);

        return new Config(
            $this->getFromServices('client_id'),
            $this->getFromServices('client_secret'),
            $this->getFromServices('redirect'),
            $this->getConfigItems($additionalConfigKeys, function ($key) {
                return $this->getFromServices(strtolower($key));
            })
        );
    }
1020295
public function signInWithProvider($provider_name, Request $request)
    {
        $provider = $this->getProvider($provider_name, $request);

        if (!$provider) {
            return $this->response(['errors' => [
                'code'    => 'PROVIDER_NOT_FOUND',
                'message' => 'No provider found',
            ]], Response::HTTP_BAD_REQUEST);
        }

        $provider->stateless();

        if ($request->input('code') !== null) {
            try {
                return $this->authenticateByCode($provider, $request->input('code'));
            } catch (\Exception $e) {
                return $this->response([
                    'code'    => 'CODE_NOT_VALID',
                    'message' => 'Code invalid or expired'.$e->getMessage(),
                ], Response::HTTP_BAD_REQUEST);
            }
        }
    }
139864
public function register($provider)
    {
        if (! $provider instanceof ServiceProvider) {
            $provider = new $provider($this);
        }

        if (array_key_exists($providerName = get_class($provider), $this->loadedProviders)) {
            return;
        }

        $this->loadedProviders[$providerName] = $provider;

        if (method_exists($provider, 'register')) {
            $provider->register();
        }

        if ($this->booted) {
            $this->bootProvider($provider);
        }
    }
201145
public function bind($key, $binder)
    {
        $this->binders[str_replace('-', '_', $key)] = RouteBinding::forCallback(
            $this->container, $binder
        );
    }
641324
public function setSMSAPICredential($provider, $credentials = array())
    {
        $this->checkCredentialManagementRights();

        $smsProviderInstance = SMSProvider::factory($provider);
        $smsProviderInstance->verifyCredential($credentials);

        $settings = $this->getCredentialManagerSettings();

        $settings[MobileMessaging::PROVIDER_OPTION] = $provider;
        $settings[MobileMessaging::API_KEY_OPTION] = $credentials;

        $this->setCredentialManagerSettings($settings);

        return true;
    }
1257239
public function handleProviderCallback($provider)
    {
        try {
            $user = $this->socialProvider->driver($provider)->user();
        } catch (Exception $e) {
            return Redirect::to('auth/' . $provider);
        }

        $this->auth->login($this->users->provider($provider)->findOrCreateUser($user), true);

        return redirect()->intended($this->redirectPath());
    }
685825
private function getProviderDetails($provider)
    {
        if (empty($this->providers)) {
            throw new \Exception('No Providers have been set in users config.');
        }

        $provider = is_null($provider) ? $this->providers->first() : $this->providers->get($provider);

        if (is_null($provider['driver'])) {
            throw new \InvalidArgumentException('You must set a social driver to use the social authenticating features.');
        }

        $this->driver = $provider['driver'];
        $this->scopes = $provider['scopes'];
        $this->extras = $provider['extras'];
    }
92619
public function addProvider($provider)
    {
        if ($provider instanceof Provider) {
            $this->providers[] = $provider;
        }

        if (is_array($provider)) {
            $this->providers[] = new Provider(
                $provider['endpoint'],
                $provider['schemes'],
                $provider['url'],
                $provider['name']
            );
        }
    }
441750
public function setProvider(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider = null)
    {
        $this->provider = $provider;

        return $this;
    }
542521
protected function doAuth($provider, TokenInterface $token)
    {
        if (! $provider instanceof ApiKeyUserProviderInterface) {
            return false;
        }

        /** @var UserInterface $user */
        $user = $provider->loadUserByApiKey($token->getCredentials());

        if ($user) {
            $authenticatedToken = new ApiKeyUserToken($user->getRoles());
            $authenticatedToken->setUser($user);

            return $authenticatedToken;
        }

        throw new AuthenticationException("The API Key authentication failed.");
    }
1138545
public function register($provider, $options = [], $force = false){
		if(!isset($this->providers[$provider]) || $force){
			$this->providers[$provider] = new $provider($this,$options);
			with($this->providers[$provider])->register();
		}
	}
897283
public function createAuthenticationProvider(\Silex\Application $app,
                                                 UserProviderInterface $userProvider,
                                                 $providerKey)
    {
        return new SimpleAuthenticationProvider($this->simpleAuthenticator, $userProvider, $providerKey);
    }