Choose an Auth Method for the Bridge.

@param Bridge $bridge
@param string $username
@param string $authMethod

@return Bridge
184929
protected function chooseAuthMethodForBridge(Bridge $bridge, $username, $authMethod = null)
    {
        // Check if an auth method is passed explicitly.
        if (! is_null($authMethod) && collect(config('watson-bridge.auth_methods'))->contains($authMethod)) {
            $bridge->useAuthMethodAs($authMethod);

            // Auth method is token so we need to set Token.
            if ($authMethod == 'token') {
                $bridge->setToken($username);
            }
        }

        return $bridge;
    }
412178
public function setBasicAuth(string $username, string $password)
    {
        $this->basicAuthUsername = $username;
        $this->basicAuthPassword = $password;
        return $this;
    }
917161
public function setBasicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;

        return $this;
    }
76948
public function login($userName, $password, AccessControlEvent $event)
    {
        $authCookie = $this->requestStack->getCurrentRequest()->cookies->get($this->authTokenName);

        // Remove expired tokens
        $this->getRepositoryAuthtoken()->deleteExpiredTokens();

        if ($userName !== null && $password !== null) {
            return $this->loginCheckUser($userName, $password, $event);
        } elseif ($authCookie !== null) {
            return $this->loginCheckAuthtoken($authCookie, $event);
        }

        $this->systemLogger->error('Login function called with empty username/password combination, or no authentication token.', ['event' => 'security']);
        throw new AccessControlException('Invalid login parameters.');
    }
139925
public function authenticate($username, $password) {

    // Get some things.
    $client = $this->getClient();
    $parameters = $this->getAuthParams();
    $endpoint = $this->getEndpoint();
    $code = NULL;

    $response = $client->get($endpoint,
      ['query' => $parameters, 'auth' => [$username, $password]]
    );

    $code = $response->getStatusCode();
    $this->setLastResponse($response);

    // @todo: handle non 200 responses with error logging.
    switch ($code) {
      case '200':
        $body = $response->getBody();
        $json = json_decode($body->getContents());
        if (empty($json)) {
          throw new \Exception("Could not get JSON from body.");
        }
        $this->setAuthApiToken($json->access_token);
        $this->setAuthApiTokenExpires($json->expires_in);
        break;
    }

    return $this;
  }
1119318
public function login($username, $password)
    {
        $model       = $this->slice->getRequired('model');
        $loginFields = $this->slice->getRequired('loginFields');
        $hashField   = $this->slice->getRequired('hashField');

        $userQuery = $this->provider->auth()->orm()->repository($model);

        foreach ($loginFields as $field)
        {
            $userQuery->whereOr($field, $username);
        }

        $user = $userQuery->findOne();

        if ($user && $this->verify($password, $user->get($hashField)))
        {
            $this->provider->setUser($user);
        }

        return $user;
    }
550291
public function setAuthorization($username, $password)
    {
        $this->username = $username;
        $this->password = $password;

        return $this;
    }
897621
public static function getInstance($auth_domain_id, $username)
	{
		$row = self::all()
			->whereEquals('auth_domain_id', $auth_domain_id)
			->whereEquals('username', $username)
			->row();

		if (!$row || !$row->get('id'))
		{
			return false;
		}

		return $row;
	}
742296
public function login(?string $username, ?string $password)
    {
        try {
            $this->startBrokerSession();

            if (!$username || !$password) {
                $this->fail('No username and/or password provided.');
            }

            if (!$this->authenticate($username, $password)) {
                $this->fail('User authentication failed.');
            }
        } catch (SSOServerException $e) {
            return $this->returnJson(['error' => $e->getMessage()]);
        }

        $this->setSessionData('sso_user', $username);

        return $this->userInfo();
    }
976726
public function userLogin($username, $password)
    {
        return $this->requestHandler->sendRequestAsync('POST', 'api/v4/users/login/',
            [
                'form_params' => [
                    'username' => $username,
                    'password' => $password
                ]
            ])->then(
            function ($result) {
                $this->requestHandler->setAccessTokenCredentials($result['tokenKey'], $result['tokenSecret']);
                return $result;
            }
        );
    }
1015129
public static function login($userLogin, $userPassword)
    {
        try {
            $user = self::authenticate($userLogin, $userPassword);
            $loggedIn = self::startSession($user);
        } catch (common_user_auth_AuthFailedException $e) {
            $loggedIn = false;
        }
        return $loggedIn;
    }
849428
public function basicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
466920
public function authenticate($token, $authMethod = self::AUTH_URL_TOKEN, $sudo = null)
    {
        $this->httpClientBuilder->removePlugin(Authentication::class);
        $this->httpClientBuilder->addPlugin(new Authentication($authMethod, $token, $sudo));

        return $this;
    }
228898
public function setAuth($username, $password)
    {
        if (!empty($username) && !empty($password)) {
            $this->username = stripslashes(trim($username));
            $this->password = stripslashes(trim($password));
        }
    }
1002947
public function authenticate($username, $password) {
        if (!$this->hasPDO()) {
            return NULL;
        }

        $sql = $this->sql();

        /* @var $pdo \PDO */
        $pdo = $this->options["pdo"];
        $statement = $pdo->prepare($sql);
        $statement->execute(array($username));

        $success = false;
        $user = $statement->fetch(\PDO::FETCH_ASSOC);

        if ($user) {
            $success = password_verify($password, $user[$this->options["hash"]]);
        }

        if (!$success) {
            $this->error = new \SlimPower\Authentication\Error();
            return null;
        } else {
            $data = array();

            foreach ($this->options["show"] as $fieldname) {
                if (array_key_exists($fieldname, $user)) {
                    $data[$fieldname] = $user[$fieldname];
                }
            }

            return $data;
        }
    }
209416
public function amHttpAuthenticated($username, $password)
    {
        if ($this->isFunctional) {
            $this->client->setServerParameter('PHP_AUTH_USER', $username);
            $this->client->setServerParameter('PHP_AUTH_PW', $password);
        } else {
            $this->client->setAuth($username, $password);
        }
    }
1307095
public static function create(AuthApiInterface $authProvider, $projectId, $logger = null)
    {

        $client = self::initializeHttpClient(self::ENDPOINT_URL);

        $instance = new self($projectId, $client, $logger, self::ENDPOINT_URL);
        $instance->setAuth($authProvider);

        return $instance;
    }