Browse Source

Remove stubs to support non-HTTP authentication

Also removes authPreferHTTP setting
microsub
J. King 7 years ago
parent
commit
c800852f3a
  1. 1
      lib/Conf.php
  2. 2
      lib/Feed.php
  3. 35
      lib/User.php
  4. 1
      tests/User/TestAuthorization.php
  5. 1
      tests/lib/User/CommonTests.php
  6. 1
      tests/test.php

1
lib/Conf.php

@ -25,7 +25,6 @@ class Conf {
public $dbMySQLAutoUpd = false;
public $userDriver = User\Internal\Driver::class;
public $userAuthPreferHTTP = false;
public $userComposeNames = true;
public $userTempPasswordLength = 20;

2
lib/Feed.php

@ -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

@ -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;

1
tests/User/TestAuthorization.php

@ -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) {

1
tests/lib/User/CommonTests.php

@ -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);

1
tests/test.php

@ -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…
Cancel
Save