Initial service DAV module

This commit is contained in:
Sebastian Krupinski
2026-07-14 18:22:40 -04:00
parent b9302bf965
commit 3b07d6721b
497 changed files with 73793 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace KTXM\ServiceDav\Auth;
use KTXC\Service\SecurityService;
use KTXC\SessionIdentity;
use Sabre\DAV\Auth\Backend\AbstractBasic;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
class DavAuthBackend extends AbstractBasic
{
public const PRINCIPAL_PREFIX = 'principals/';
public function __construct(
private readonly SessionIdentity $identity,
private readonly SecurityService $securityService,
string $realm = 'KTXC DAV',
) {
$this->realm = $realm;
}
public function check(RequestInterface $request, ResponseInterface $response): array
{
if ($this->identity->identity() !== null) {
$userId = $this->identity->identifier();
return [true, self::PRINCIPAL_PREFIX . $userId];
}
return parent::check($request, $response);
}
protected function validateUserPass($username, $password): bool
{
$user = $this->securityService->authenticatePassword($username, $password);
if ($user === null) {
return false;
}
$this->identity->initialize($user, false);
return true;
}
}