mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Remove stubs to support non-HTTP authentication
Also removes authPreferHTTP setting
This commit is contained in:
parent
835eff9a9e
commit
c800852f3a
6 changed files with 5 additions and 36 deletions
|
@ -25,7 +25,6 @@ class Conf {
|
|||
public $dbMySQLAutoUpd = false;
|
||||
|
||||
public $userDriver = User\Internal\Driver::class;
|
||||
public $userAuthPreferHTTP = false;
|
||||
public $userComposeNames = true;
|
||||
public $userTempPasswordLength = 20;
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ class Feed {
|
|||
// if there are no tentatively new articles and/or the number of stored articles is less than the size of the feed, don't do a second pass; assume any tentatively new items are in fact new
|
||||
$new = $tentative;
|
||||
}
|
||||
// FIXME: fetch full content when appropriate
|
||||
// TODO: fetch full content when appropriate
|
||||
foreach($new as $index) {
|
||||
$this->newItems[] = $items[$index];
|
||||
}
|
||||
|
|
35
lib/User.php
35
lib/User.php
|
@ -87,20 +87,6 @@ class User {
|
|||
}
|
||||
|
||||
public function credentials(): array {
|
||||
if(Data::$conf->userAuthPreferHTTP) {
|
||||
return $this->credentialsHTTP();
|
||||
} else {
|
||||
return $this->credentialsForm();
|
||||
}
|
||||
}
|
||||
|
||||
public function credentialsForm(): array {
|
||||
// FIXME: stub
|
||||
$this->id = "john.doe@example.com";
|
||||
return ["user" => "john.doe@example.com", "password" => "secret"];
|
||||
}
|
||||
|
||||
public function credentialsHTTP(): array {
|
||||
if($_SERVER['PHP_AUTH_USER']) {
|
||||
$out = ["user" => $_SERVER['PHP_AUTH_USER'], "password" => $_SERVER['PHP_AUTH_PW']];
|
||||
} else if($_SERVER['REMOTE_USER']) {
|
||||
|
@ -117,8 +103,7 @@ class User {
|
|||
|
||||
public function auth(string $user = null, string $password = null): bool {
|
||||
if($user===null) {
|
||||
if(Data::$conf->userAuthPreferHTTP) return $this->authHTTP();
|
||||
return $this->authForm();
|
||||
return $this->authHTTP();
|
||||
} else {
|
||||
$this->id = $user;
|
||||
$this->actor = [];
|
||||
|
@ -135,17 +120,10 @@ class User {
|
|||
}
|
||||
}
|
||||
|
||||
public function authForm(): bool {
|
||||
$cred = $this->credentialsForm();
|
||||
if(!$cred["user"]) return $this->challengeForm();
|
||||
if(!$this->auth($cred["user"], $cred["password"])) return $this->challengeForm();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function authHTTP(): bool {
|
||||
$cred = $this->credentialsHTTP();
|
||||
if(!$cred["user"]) return $this->challengeHTTP();
|
||||
if(!$this->auth($cred["user"], $cred["password"])) return $this->challengeHTTP();
|
||||
$cred = $this->credentials();
|
||||
if(!$cred["user"]) return false;
|
||||
if(!$this->auth($cred["user"], $cred["password"])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -358,11 +336,6 @@ class User {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: stubs
|
||||
public function challenge(): bool {throw new User\Exception("authFailed");}
|
||||
public function challengeForm(): bool {throw new User\Exception("authFailed");}
|
||||
public function challengeHTTP(): bool {throw new User\Exception("authFailed");}
|
||||
|
||||
protected function composeName(string $user): string {
|
||||
if(preg_match("/.+?@[^@]+$/",$user)) {
|
||||
return $user;
|
||||
|
|
|
@ -50,7 +50,6 @@ class TestAuthorization extends \PHPUnit\Framework\TestCase {
|
|||
$this->clearData();
|
||||
$conf = new Conf();
|
||||
$conf->userDriver = $drv;
|
||||
$conf->userAuthPreferHTTP = true;
|
||||
$conf->userComposeNames = true;
|
||||
Data::$conf = $conf;
|
||||
if($db !== null) {
|
||||
|
|
|
@ -13,7 +13,6 @@ trait CommonTests {
|
|||
$this->clearData();
|
||||
$conf = new Conf();
|
||||
$conf->userDriver = $this->drv;
|
||||
$conf->userAuthPreferHTTP = true;
|
||||
Data::$conf = $conf;
|
||||
Data::$db = new Database();
|
||||
Data::$user = Phake::PartialMock(User::class);
|
||||
|
|
|
@ -10,7 +10,6 @@ $_SERVER['PHP_AUTH_USER'] = $user;
|
|||
$_SERVER['PHP_AUTH_PW'] = $pass;
|
||||
$conf = new Conf();
|
||||
$conf->dbSQLite3File = ":memory:";
|
||||
$conf->userAuthPreferHTTP = true;
|
||||
Data::load($conf);
|
||||
Data::$db->schemaUpdate();
|
||||
|
||||
|
|
Loading…
Reference in a new issue