Verify connection credentials.

@since 2.0.17
@access public
437275
public function Verify() {
      $CredentialsValid = Gdn::Statistics()->ValidateCredentials();
      $this->SetData('StatisticsVerified', $CredentialsValid);
      $this->Render();
   }
95896
protected static function authenticate() :void {
		// if we did not authenticate before
		if(!self::$_account) {
			// search for an enabled account with that session key and a non expired session
			$account = \Models\Accounts::getFirstEnabledWithNonExpiredSession(
				// the session key
				Cook::get(Config::get('security', 'cookie'))
			);
			// if the cookie session key doesn't match any existing account session, we deny access
			$account ?: 
				self::refuse(
					'Your session is no longer valid', 
					403, true);
			// if the stored key and dynamically generated mismatch, we deny access
			$account->hasMatchingDynamicKey() ?: 
				self::refuse(
					'Your signature has changed since your last visit, please log-in again', 
					403, true);
			// if account has expired, we deny access
			!$account->hasItsValidityExpired() ?:
				self::refuse(
					"Your account has expired, it was valid until {$account->get('account_expiration_date')}", 
					403, true);
			// update our credentials
			self::$_account = $account;
			// set access as granted
			self::$_granted = true;
		}	
	}
940269
public function connect()
    {
        if ($this->isConnected) {
            return false;
        }

        if (!$this->pdo) {
            $this->beforeConnect && call_user_func($this->beforeConnect, $this);

            $dsn = $this->getDsn();
            $attrs = $this->attrs + array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_STRINGIFY_FETCHES => true,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
            );

            try {
                $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
            } catch (\PDOException $e) {
                $this->connectFails && call_user_func($this->connectFails, $this, $e);
                throw $e;
            }

            $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
        }

        $this->isConnected = true;

        return true;
    }
1191231
public function connectionSettingsAreValid()
    {
        // if there is no adapter how can we initialize the correct validator to check it
        if (!$this->getDbAdapter()) {
            return false;
        }

        /**
         * @var MySQLConnectionSettings $connectionSettings
         */
        $connectionSettings = $this->getDbAdapter()->getConnectionSettings();
        if (!$connectionSettings) {
            return false;
        }

        return $connectionSettings->validateProperties();
    }
156814
def check_credentials(self):
        '''  '''
        req = requests.get(self.api_server + '/api/ad',
                           auth=(self.access_key, self.secret_key))
        # Not sure 500 server error should be included here
        if req.status_code in [401, 403, 500]:
            return False
        else:
            return True
600032
protected function checkConnection()
    {
        // If the connection could not be established, fsockopen sadly does not
        // only return false (as documented), but also always issues a warning.
        if ( ( $this->connection === null ) &&
             ( ( $this->connection = @fsockopen( $this->options['ip'], $this->options['port'], $errno, $errstr ) ) === false ) )
        {
            // This is a bit hackisch...
            $this->connection = null;
            throw new phpillowConnectionException(
                "Could not connect to server at %ip:%port: '%errno: %error'",
                array(
                    'ip'    => $this->options['ip'],
                    'port'  => $this->options['port'],
                    'error' => $errstr,
                    'errno' => $errno,
                )
            );
        }
    }
522721
public function isSecureConnection()
    {
        return isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'], 'on') === 0 || $_SERVER['HTTPS'] == 1)
        || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0;
    }
403380
public function verify()
    {
        $phpversion = phpversion();
        $extensions = get_loaded_extensions();
        $ini        = array_only(ini_get_all(), ['max_execution_time', 'max_file_uploads', 'max_input_time', 'post_max_size', 'upload_max_filesize']);

        $return              = [
            'version'    => $phpversion,
            'transports' => implode(', ', stream_get_transports()),
            'filters'    => implode(', ', stream_get_filters()),
            'doc_root'   => getcwd(),
            'extensions' => $extensions,
            'ini'        => $ini,
        ];
        $this->configuration = $return;
        $this->validate($return);
        return $return;
    }
1185686
def verify_state(self):
        """"""
        if self.state == CONNECTING:
            self.state = OPEN

            self.conn.on_open(self.conn_info)
555102
static function isTrusted()
    {
        $ini = eZINI::instance();

        // Check if current user is trusted user.
        $trustedIPs = $ini->hasVariable( 'UserSettings', 'TrustedIPList' ) ? $ini->variable( 'UserSettings', 'TrustedIPList' ) : array();

        // Check if IP address of current user is in $trustedIPs array.
        $trustedUser = eZUser::isUserIPInList( $trustedIPs );
        if ( $trustedUser )
            return true;

        return false;
    }
53978
protected function checkConnection()
    {
        // Setting Connection scheme according ssl support
        if ($this->options['ssl']) {
            if (!extension_loaded('openssl')) {
                // no openssl extension loaded.
                // This is a bit hackisch...
                $this->connection = null;

                throw HTTPException::connectionFailure(
                    $this->options['ip'],
                    $this->options['port'],
                    'ssl activated without openssl extension loaded',
                    0
                );
            }

            $host = 'ssl://'.$this->options['host'];
        } else {
            $host = $this->options['ip'];
        }

        // If the connection could not be established, fsockopen sadly does not
        // only return false (as documented), but also always issues a warning.
        if (($this->connection === null) &&
             (($this->connection = @fsockopen($host, $this->options['port'], $errno, $errstr, $this->options['timeout'])) === false)) {
            // This is a bit hackisch...
            $this->connection = null;
            throw HTTPException::connectionFailure(
                $this->options['ip'],
                $this->options['port'],
                $errstr,
                $errno
            );
        }
    }
801496
private function connection_init()
    {
        $opts = $this->config;

        // Headers format
        $headers = [];
        foreach ($opts['headers'] as $key => $value)
            $headers[] = "$key: $value";

        $connection = new JsonRPC\Client($opts['url'], $opts['timeout'], $headers);

        $connection->ssl_verify_peer = $opts['ssl_verify_peer'];
        $connection->debug           = $opts['debug'];
        $connection->named_arguments = isset($opts['named_arguments']) && $opts['named_arguments']===true;

        if (isset($opts['username']) && $opts['username']) {
            $connection->authentication($opts['username'], $opts['password']);
        }

        return $connection;
    }
818746
def _verify_credentials(self):
        
        r = requests.get(self.apiurl + "account/verify_credentials.xml",
                         auth=HTTPBasicAuth(self._username, self._password),
                         headers=self.header)
        if r.status_code != 200:
            raise UserLoginFailed("Username or Password incorrect.")
137340
public function checkBE()
	{
	    if ($this->isContao45()) 
	    {
	        if ($this->_BackendUser)
	        {
                ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': True' );
                return true;
	        }
	        ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': False' );
	        return false;
	    }
		//Contao <4.5.0
	    $strCookie = 'BE_USER_AUTH';
		$hash = sha1(session_id() . (!\Config::get('privacyAnonymizeIp') ? \Environment::get('ip') : '') . $strCookie);
		if (\Input::cookie($strCookie) == $hash)
		{
			// Try to find the session
			$objSession = \SessionModel::findByHashAndName($hash, $strCookie);
			// Validate the session ID and timeout
			if ($objSession !== null && $objSession->sessionID == session_id() && (\Config::get('privacyAnonymizeIp') || $objSession->ip == \Environment::get('ip')) && ($objSession->tstamp + $GLOBALS['TL_CONFIG']['sessionTimeout']) > time())
			{
			    ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': True' );
				return true;
			}
		}
		ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': False' );
		return false;
	}
248070
public function authenticate()
    {
        $hmac = $this->getRest()->getServer()->getHmac();
        $data = array_merge($this->getRequestHeaders(true), $this->getBodyData());
        $auth = $hmac->setData($data)
                     ->setRoute($this->getPlatform()->getPost('api_method'))
                     ->setMethod($_SERVER['REQUEST_METHOD'])
                     ->auth($this->settings['api_key'], $this->settings['api_secret']);
        
        if(!$auth) {
            return false;
        }
        
        return true;
    }
740026
protected function validateOauthCredential()
    {
        if (!$this->isPosted('save')) {
            return false;
        }

        $this->setSubmitted('credential');
        $this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
        $this->validateElement(array('data.id' => $this->text('Client ID')), 'length', array(1, 255));
        $this->validateElement(array('data.secret' => $this->text('Client secret')), 'length', array(1, 255));

        return !$this->hasErrors();
    }
642758
public function authenticate(): bool
    {
        if (isset($_GET['access_token'])) {
            $this->logger->warning('found access_token in query string, you should use a bearer token instead due security reasons https://tools.ietf.org/html/rfc6750#section-2.3', [
                'category' => get_class($this),
            ]);

            return $this->verifyToken($_GET['access_token']);
        }
        if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
            $header = $_SERVER['HTTP_AUTHORIZATION'];
            $parts = explode(' ', $header);

            if ('Bearer' === $parts[0]) {
                $this->logger->debug('found http bearer authorization header', [
                    'category' => get_class($this),
                ]);

                return $this->verifyToken($parts[1]);
            }
            $this->logger->debug('no bearer token provided', [
                    'category' => get_class($this),
                ]);

            return false;
        }

        $this->logger->debug('http authorization header contains no bearer string or invalid authentication string', [
                    'category' => get_class($this),
                ]);

        return false;
    }