Check if client authorization data is valid
@codeCoverageIgnore
@param ClientAuth $clientAuth
@return bool
510585
public final function isValidAuth(ClientAuth $clientAuth) {
		return $clientAuth->publicKey === $this->getPublicKey() && $clientAuth->token === $this->getToken();
	}
430095
public function authenticateClientIp($clientIp)
    {
        if (false === IpUtils::checkIp($clientIp, self::$xsollaSubnets)) {
            throw new InvalidClientIpException(sprintf(
                'Client IP address (%s) not found in allowed IP addresses whitelist (%s). Please check troubleshooting section in README.md https://github.com/xsolla/xsolla-sdk-php#troubleshooting',
                $clientIp,
                implode(', ', self::$xsollaSubnets)
            ));
        }
    }
1181843
private function validateCsrfTokenInternal($clientSuppliedToken, $trueToken)
    {
        if (!is_string($clientSuppliedToken)) {
            return false;
        }

        $security = $this->app->security;

        return $security->unmaskToken($clientSuppliedToken) === $security->unmaskToken($trueToken);
    }
1122784
public function verify($token)
    {
        try {
            $this->client()->head('authentication-tokens/{token}', ['token' => $token]);

            return true;
        } catch (NotFoundException $e) {
            return false;
        }
    }
270980
public function checkRestrictedGrantType($clientUuid, $grantType)
    {
        $client = $this->getClientDataMapper()->findByUuid($clientUuid);

        if (! $client instanceof Entity\Client) {
            return false;
        }

        $clientGrantTypes = $client->getGrantTypes();

        if (empty($clientGrantTypes)) {
            return true;
        }

        return in_array($grantType, $clientGrantTypes);
    }
1145846
public function isValid($authUser, $authPass)
    {
        // add realm if requested
        if (null !== $this->realm) {
            $authUser = sprintf('%s@%s', $authUser, $this->realm);
        }

        $radiusAuth = radius_auth_open();

        foreach ($this->serverList as $radiusServer) {
            if (false === radius_add_server(
                $radiusAuth,
                $radiusServer['host'],
                \array_key_exists('port', $radiusServer) ? $radiusServer['port'] : 1812,
                $radiusServer['secret'],
                5,  // timeout
                3   // max_tries
            )) {
                $errorMsg = sprintf('RADIUS error: %s', radius_strerror($radiusAuth));
                $this->logger->error($errorMsg);

                throw new RadiusException($errorMsg);
            }
        }

        if (false === radius_create_request($radiusAuth, RADIUS_ACCESS_REQUEST)) {
            $errorMsg = sprintf('RADIUS error: %s', radius_strerror($radiusAuth));
            $this->logger->error($errorMsg);

            throw new RadiusException($errorMsg);
        }

        radius_put_attr($radiusAuth, RADIUS_USER_NAME, $authUser);
        radius_put_attr($radiusAuth, RADIUS_USER_PASSWORD, $authPass);
        if (null !== $this->nasIdentifier) {
            radius_put_attr($radiusAuth, RADIUS_NAS_IDENTIFIER, $this->nasIdentifier);
        }

        if (RADIUS_ACCESS_ACCEPT === radius_send_request($radiusAuth)) {
            return new UserInfo($authUser, []);
        }

        if (RADIUS_ACCESS_REJECT === radius_send_request($radiusAuth)) {
            // wrong authUser/authPass
            return false;
        }

        $errorMsg = sprintf('RADIUS error: %s', radius_strerror($radiusAuth));
        $this->logger->error($errorMsg);

        throw new RadiusException($errorMsg);
    }
951432
public function authenticate($grantType = 'client_credentials')
    {
        if ($grantType == 'client_credentials') {
            $cc = new oAuthClientCredentials;
            $this->authorization = $cc->clientCredentials();
        } elseif ($grantType = 'authorization_code') {
            // Authentication has already taken place so we just need an instance of authCode
            // that has the necessary credentials
            $this->authorization = new oAuthAuthorizationCode();
        } else {
            // Unknown grant type
            return false;
        }

        return $this;
    }
1084820
public function isValid($headersOnly = false)
  {
    $accessToken = $this->determineAccessToken($headersOnly);

    $result = $this->storages['session']->validateAccessToken($accessToken);

    if ( ! $result) {
      throw new InvalidAccessTokenException('Access token is not valid');
    }

    $this->accessToken = $accessToken;
    $this->sessionId = $result['session_id'];
    $this->clientId = $result['client_id'];
    $this->ownerType = $result['owner_type'];
    $this->ownerId = $result['owner_id'];

    $sessionScopes = $this->storages['session']->getScopes($this->accessToken);
    foreach ($sessionScopes as $scope) {
      $this->sessionScopeIds[] = $scope['id'];
      $this->sessionScopes[]   = $scope['scope'];
    }

    return true;
  }
1090179
public static function fetchClient($client_id, $client_secret = null)
	{
		$query = DB::table('oauth_clients')->where('id', $client_id);
		if (null !== $client_secret) {
			$query->where('secret', $client_secret);
		}
		$client = $query->first();
		
		if (!$client) {
			return null;
		}
		
		return new Authentication\Client($client_id, (array) $client);
	}
172386
public function revokeAllAuthority($authorization, $client_id) {
        $instance = new revokeAllAuthority($this, $this->getUserAgent(), $authorization, $client_id);
        return $instance;
    }
64265
public function isConnected(OAuthToken $accessToken = null) {

		/**
		 * @var $service \yii\authclient\BaseOAuth
		 */

		if ($accessToken === null) {
			$accessToken = $this->service->getAccessToken();
		}

		if (is_object($accessToken) && $accessToken->getIsValid()) {
			return true;
		} else {

			return false;
		}
	}
175318
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
    {
        $query = null;

        if (!is_null($redirectUri) && is_null($clientSecret)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        } elseif (!is_null($clientSecret) && is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_clients.name as name')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret);
        } elseif (!is_null($clientSecret) && !is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        }

        if ($this->limitClientsToGrants === true && !is_null($grantType)) {
            $query = $query->join('oauth_client_grants', 'oauth_clients.id', '=', 'oauth_client_grants.client_id')
                   ->join('oauth_grants', 'oauth_grants.id', '=', 'oauth_client_grants.grant_id')
                   ->where('oauth_grants.id', $grantType);
        }

        $result = $query->first();

        if (is_null($result)) {
            return;
        }

        return $this->hydrateEntity($result);
    }
51918
public function isAuthenticated()
    {
        $client = parent::getHttpClient();
        if ($client->getClientLoginToken() ||
            $client->getAuthSubToken()
        ) {
            return true;
        }

        return false;
    }
203254
def check_authorization(self, access_token):
        
        p = self._session.params
        auth = (p.get('client_id'), p.get('client_secret'))
        if access_token and auth:
            url = self._build_url('applications', str(auth[0]), 'tokens',
                                  str(access_token))
            resp = self._get(url, auth=auth, params={
                'client_id': None, 'client_secret': None
            })
            return self._boolean(resp, 200, 404)
        return False
373187
public static function authorize($clientID, $clientSecret)
    {
        return json_decode(
            (new AuthorizationRequest($clientID, $clientSecret))->execute()->getBody(), true
        );
    }
174378
protected function valid($token)
    {
        try {
            (new HttpClient)->get(
                $this->sparkUrl.'/api/token/'.$token.'/validate',
                ['verify' => __DIR__.'/cacert.pem']
            );

            return true;
        } catch (Exception $e) {
            var_dump($e->getMessage());

            return false;
        }
    }
437138
public function isPublicClient($client_id)
	{
		// get client details
		$client = $this->getClientDetails($client_id);

		// make sure its an available client (aka not deleted)
		return $client && $client['state'] != 2 ? true : false;
	}