3 * @file src/Network/FKOAuth1.php
5 namespace Friendica\Network;
7 use Friendica\BaseObject;
8 use Friendica\Core\Logger;
9 use Friendica\Core\Session;
10 use Friendica\Database\DBA;
12 use OAuthSignatureMethod_HMAC_SHA1;
13 use OAuthSignatureMethod_PLAINTEXT;
16 * @brief OAuth protocol
18 class FKOAuth1 extends OAuthServer
23 public function __construct()
25 parent::__construct(new FKOAuthDataStore());
26 $this->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
27 $this->add_signature_method(new OAuthSignatureMethod_HMAC_SHA1());
31 * @param string $uid user id
33 * @throws HTTPException\ForbiddenException
34 * @throws HTTPException\InternalServerErrorException
36 public function loginUser($uid)
38 Logger::log("FKOAuth1::loginUser $uid");
39 $a = BaseObject::getApp();
40 $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
42 if (!DBA::isResult($record)) {
43 Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), Logger::DEBUG);
44 header('HTTP/1.0 401 Unauthorized');
45 die('This api requires login');
48 Session::setAuthenticatedForUser($a, $record, true);