generated from Nodarx/template
refactor: migrate to scoped execution contexts
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
+10
-10
@@ -9,8 +9,8 @@ use KTXC\Http\Request\Request;
|
||||
use KTXC\Http\Response\Response;
|
||||
use KTXC\Http\Response\StreamedResponse;
|
||||
use KTXC\Service\SecurityService;
|
||||
use KTXC\SessionIdentity;
|
||||
use KTXC\SessionTenant;
|
||||
use KTXC\Context\IdentityContextInterface;
|
||||
use KTXC\Context\TenantContextInterface;
|
||||
use KTXM\ChronoManager\Conversion\IcalDecoder;
|
||||
use KTXM\ChronoManager\Conversion\IcalEncoder;
|
||||
use KTXM\ChronoManager\Manager as ChronoManager;
|
||||
@@ -41,8 +41,8 @@ class DavServer
|
||||
private const BASE_URI = '/dav/';
|
||||
|
||||
public function __construct(
|
||||
private readonly SessionTenant $tenant,
|
||||
private readonly SessionIdentity $identity,
|
||||
private readonly TenantContextInterface $tenantContext,
|
||||
private readonly IdentityContextInterface $identityContext,
|
||||
private readonly SecurityService $securityService,
|
||||
private readonly DocumentsManager $documentsManager,
|
||||
private readonly ChronoManager $chronoManager,
|
||||
@@ -99,26 +99,26 @@ class DavServer
|
||||
|
||||
private function buildServer(): Server
|
||||
{
|
||||
$principalBackend = new PrincipalBackend($this->identity, $this->tenant);
|
||||
$calDavBackend = new CalDavBackend($this->chronoManager, $this->identity, $this->tenant, $this->uriMap, new IcalEncoder(), new IcalDecoder());
|
||||
$cardDavBackend = new CardDavBackend($this->peopleManager, $this->identity, $this->tenant, $this->uriMap);
|
||||
$principalBackend = new PrincipalBackend($this->identityContext, $this->tenantContext);
|
||||
$calDavBackend = new CalDavBackend($this->chronoManager, $this->identityContext, $this->tenantContext, $this->uriMap, new IcalEncoder(), new IcalDecoder());
|
||||
$cardDavBackend = new CardDavBackend($this->peopleManager, $this->identityContext, $this->tenantContext, $this->uriMap);
|
||||
|
||||
$server = new Server([
|
||||
new PrincipalCollection($principalBackend, PrincipalBackend::PRINCIPAL_PREFIX),
|
||||
new CalendarRoot($principalBackend, $calDavBackend),
|
||||
new AddressBookRoot($principalBackend, $cardDavBackend),
|
||||
new FilesRootNode($this->documentsManager, $this->identity, $this->tenant),
|
||||
new FilesRootNode($this->documentsManager, $this->identityContext, $this->tenantContext),
|
||||
]);
|
||||
$server->setBaseUri(self::BASE_URI);
|
||||
$server->debugExceptions = $this->debug;
|
||||
|
||||
// Authentication plugin — short-circuits when JWT/Bearer already populated
|
||||
$authBackend = new DavAuthBackend($this->identity, $this->securityService);
|
||||
$authBackend = new DavAuthBackend($this->identityContext, $this->securityService);
|
||||
$server->addPlugin(new AuthPlugin($authBackend));
|
||||
|
||||
// DAVACL — required for CalDAV / CardDAV principal resolution
|
||||
$aclPlugin = new DavACLPlugin();
|
||||
$userId = (string) ($this->identity->identifier() ?? 'anonymous');
|
||||
$userId = (string) ($this->identityContext->identifier() ?? 'anonymous');
|
||||
$aclPlugin->adminPrincipals = [PrincipalBackend::PRINCIPAL_PREFIX . '/' . $userId];
|
||||
$server->addPlugin($aclPlugin);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user