generated from Nodarx/template
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\ServiceDav\Controllers;
|
|
|
|
use KTXC\Http\Request\Request;
|
|
use KTXC\Http\Response\Response;
|
|
use KTXF\Controller\ControllerAbstract;
|
|
use KTXF\Routing\Attributes\AnonymousPrefixRoute;
|
|
use KTXM\ServiceDav\DavServer;
|
|
|
|
/**
|
|
* Entry-point controller for all WebDAV / CalDAV / CardDAV requests.
|
|
*
|
|
* The route is registered with absolute: true so that the path is /dav/ (not
|
|
* /m/service_dav/dav/). Authentication is intentionally left anonymous at the
|
|
* KTXC framework level because sabre's own Auth plugin — which supports both
|
|
* HTTP Basic (for DAV clients) and the existing JWT session (for browser-based
|
|
* access) — handles all credential validation.
|
|
*/
|
|
class DavController extends ControllerAbstract
|
|
{
|
|
/** All HTTP methods that any compliant DAV client may issue. */
|
|
private const DAV_METHODS = [
|
|
'GET', 'OPTIONS', 'POST', 'PUT', 'DELETE',
|
|
'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE',
|
|
'LOCK', 'UNLOCK', 'REPORT', 'ACL',
|
|
];
|
|
|
|
public function __construct(
|
|
private readonly DavServer $davServer,
|
|
) {}
|
|
|
|
#[AnonymousPrefixRoute('/dav/', name: 'service.dav', methods: self::DAV_METHODS, absolute: true)]
|
|
public function handle(Request $request): Response
|
|
{
|
|
return $this->davServer->process($request);
|
|
}
|
|
}
|