3 * @file src/Network/FKOAuth1.php
5 namespace Friendica\Network;
7 use Friendica\BaseObject;
8 use Friendica\App\Authentication;
9 use Friendica\Core\Logger;
10 use Friendica\Core\Session;
11 use Friendica\Database\DBA;
13 use OAuthSignatureMethod_HMAC_SHA1;
14 use OAuthSignatureMethod_PLAINTEXT;
17 * @brief OAuth protocol
19 class FKOAuth1 extends OAuthServer
24 public function __construct()
26 parent::__construct(new FKOAuthDataStore());
27 $this->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
28 $this->add_signature_method(new OAuthSignatureMethod_HMAC_SHA1());
32 * @param string $uid user id
34 * @throws HTTPException\ForbiddenException
35 * @throws HTTPException\InternalServerErrorException
37 public function loginUser($uid)
39 Logger::log("FKOAuth1::loginUser $uid");
40 $a = BaseObject::getApp();
41 $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
43 if (!DBA::isResult($record)) {
44 Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), Logger::DEBUG);
45 header('HTTP/1.0 401 Unauthorized');
46 die('This api requires login');
49 /** @var Authentication $authentication */
50 $authentication = BaseObject::getClass(Authentication::class);
51 $authentication->setForUser($a, $record, true);