diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9fb4410..27b30b4 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -76,9 +76,8 @@ jobs: fail-fast: false matrix: php: - - '8.1' # from 2021-11 to 2023-11 (2025-12) - - '8.2' # from 2022-12 to 2024-12 (2026-12) - '8.3' # from 2023-11 to 2025-12 (2027-12) + - '8.4' # from 2024-11 to 2026-12 (2028-12) steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 @@ -138,9 +137,8 @@ jobs: fail-fast: false matrix: php: - - '8.1' # from 2021-11 to 2023-11 (2025-12) - - '8.2' # from 2022-12 to 2024-12 (2026-12) - '8.3' # from 2023-11 to 2025-12 (2027-12) + - '8.4' # from 2024-11 to 2026-12 (2028-12) steps: - uses: actions/checkout@v4 - uses: docker://pipelinecomponents/php-codesniffer diff --git a/composer.json b/composer.json index b185bbb..2db3339 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,10 @@ } ], "require": { - "pdsinterop/solid-auth": "v0.14.2", - "pdsinterop/solid-crud": "v0.8.5", + "pdsinterop/solid-auth": "v0.15", + "pdsinterop/solid-crud": "v0.9", "phpmailer/phpmailer": "^6.10", - "sweetrdf/easyrdf": "~1.15.0", + "sweetrdf/easyrdf": ">=1.15.0 <1.16.0", "phpseclib/bcmath_compat": "^2.0", "phrity/websocket": "^3.5" }, diff --git a/lib/ProfileServer.php b/lib/ProfileServer.php index 7630524..955d914 100644 --- a/lib/ProfileServer.php +++ b/lib/ProfileServer.php @@ -8,7 +8,21 @@ class ProfileServer extends Server { - public static function getFileSystem() + public function getMimeDetector() + { + $extensionMap = new \League\MimeTypeDetection\OverridingExtensionToMimeTypeMap( + new \League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap(), + [ + 'acl' => 'text/turtle', + ], + ); + + $mimeTypeDetector = new \League\MimeTypeDetection\FinfoMimeTypeDetector( + customExtensionMap: $extensionMap, + ); + } + + public static function getRdfAdapter() { $profileId = self::getProfileId(); @@ -17,10 +31,12 @@ public static function getFileSystem() } else { $profilePath = implode("/", str_split($profileId, 4)); } + // The internal adapter - $adapter = new \League\Flysystem\Adapter\Local( + $adapter = new \League\Flysystem\Local\LocalFilesystemAdapter( // Determine root directory - PROFILEBASE . $profilePath + PROFILEBASE . $profilePath, + self::getMimeDetector() ); $graph = new \EasyRdf\Graph(); @@ -29,12 +45,12 @@ public static function getFileSystem() $serverUri = Util::getServerUri(); // Create the RDF Adapter - $rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf($adapter, $graph, $formats, $serverUri); + return new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf($adapter, $graph, $formats, $serverUri); + } + public static function getFileSystem($rdfAdapter) + { $filesystem = new \League\Flysystem\Filesystem($rdfAdapter); - $filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats)); - $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); - $filesystem->addPlugin($plugin); return $filesystem; } @@ -93,7 +109,8 @@ public static function initializeProfile() $user = self::getOwner(); if ($user) { - $filesystem = self::getFilesystem(); + $rdfAdapter = self::getRdfAdapter(); + $filesystem = self::getFilesystem($rdfAdapter); if (!$filesystem->has("/.acl")) { $defaultAcl = self::generateDefaultAcl(); $filesystem->write("/.acl", $defaultAcl); diff --git a/lib/Routes/SolidStorage.php b/lib/Routes/SolidStorage.php index 8f942a8..7146817 100644 --- a/lib/Routes/SolidStorage.php +++ b/lib/Routes/SolidStorage.php @@ -21,7 +21,8 @@ public static function respondToStorage() try { StorageServer::initializeStorage(); - $filesystem = StorageServer::getFileSystem(); + $rdfAdapter = StorageServer::getRdfAdapter(); + $filesystem = StorageServer::getFileSystem($rdfAdapter); } catch (\Exception $e) { $response = new Response(); $response = $response->withStatus(404, "Not found"); @@ -29,11 +30,11 @@ public static function respondToStorage() exit(); } - $resourceServer = new ResourceServer($filesystem, new Response(), null); + $resourceServer = new ResourceServer($filesystem, $rdfAdapter, new Response(), null); $solidNotifications = new SolidNotifications(); $resourceServer->setNotifications($solidNotifications); - $wac = new WAC($filesystem); + $wac = new WAC($filesystem, $rdfAdapter); $baseUrl = Util::getServerBaseUrl(); $resourceServer->setBaseUrl($baseUrl); diff --git a/lib/Routes/SolidUserProfile.php b/lib/Routes/SolidUserProfile.php index d900458..8c14efa 100644 --- a/lib/Routes/SolidUserProfile.php +++ b/lib/Routes/SolidUserProfile.php @@ -20,13 +20,14 @@ public static function respondToProfile() $rawRequest = $requestFactory->fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); ProfileServer::initializeProfile(); - $filesystem = ProfileServer::getFileSystem(); + $rdfAdapter = ProfileServer::getRdfAdapter(); + $filesystem = ProfileServer::getFileSystem($rdfAdapter); - $resourceServer = new ResourceServer($filesystem, new Response(), null); + $resourceServer = new ResourceServer($filesystem, $rdfAdapter, new Response(), null); $solidNotifications = new SolidNotifications(); $resourceServer->setNotifications($solidNotifications); - $wac = new WAC($filesystem); + $wac = new WAC($filesystem, $rdfAdapter); $baseUrl = Util::getServerBaseUrl(); $resourceServer->setBaseUrl($baseUrl); diff --git a/lib/StorageServer.php b/lib/StorageServer.php index 40aa5ae..1f54022 100644 --- a/lib/StorageServer.php +++ b/lib/StorageServer.php @@ -7,6 +7,7 @@ use Pdsinterop\PhpSolid\Util; use Pdsinterop\PhpSolid\Db; + class StorageServer extends Server { public static function getStorage($storageId) @@ -101,7 +102,21 @@ public static function getOwnerWebId() return false; } - public static function getFileSystem() + public function getMimeDetector() + { + $extensionMap = new \League\MimeTypeDetection\OverridingExtensionToMimeTypeMap( + new \League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap(), + [ + 'acl' => 'text/turtle', + ], + ); + + $mimeTypeDetector = new \League\MimeTypeDetection\FinfoMimeTypeDetector( + customExtensionMap: $extensionMap, + ); + } + + public static function getRdfAdapter() { $storageId = self::getStorageId(); if (!self::storageIdExists($storageId)) { @@ -114,9 +129,10 @@ public static function getFileSystem() } // The internal adapter - $adapter = new \League\Flysystem\Adapter\Local( + $adapter = new \League\Flysystem\Local\LocalFilesystemAdapter( // Determine root directory - STORAGEBASE . "$storagePath/" + STORAGEBASE . "$storagePath/", + self::getMimeDetector() ); $graph = new \EasyRdf\Graph(); @@ -125,12 +141,12 @@ public static function getFileSystem() $serverUri = Util::getServerUri(); // Create the RDF Adapter - $rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf($adapter, $graph, $formats, $serverUri); + return new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf($adapter, $graph, $formats, $serverUri); + } + public static function getFileSystem($rdfAdapter) + { $filesystem = new \League\Flysystem\Filesystem($rdfAdapter); - $filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats)); - $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); - $filesystem->addPlugin($plugin); return $filesystem; } @@ -174,7 +190,8 @@ private static function getStorageId() public static function initializeStorage() { - $filesystem = self::getFilesystem(); + $rdfAdapter = self::getRdfAdapter(); + $filesystem = self::getFilesystem($rdfAdapter); if (!$filesystem->has("/.acl")) { $defaultAcl = self::generateDefaultAcl(); $filesystem->write("/.acl", $defaultAcl); diff --git a/lib/User.php b/lib/User.php index 34ae5fe..2fcc1fa 100644 --- a/lib/User.php +++ b/lib/User.php @@ -99,7 +99,7 @@ public static function validatePasswordStrength($password) $entropy = PasswordValidator::getEntropy($password, BANNED_PASSWORDS); $minimumEntropy = MINIMUM_PASSWORD_ENTROPY; if ($entropy < $minimumEntropy) { - error_log("Entered pasword does not satisfy minimum entropy"); + error_log("Entered password does not satisfy minimum entropy"); return false; } return true; diff --git a/tests/phpunit/StorageServerTest.php b/tests/phpunit/StorageServerTest.php index c1c7fc7..22a057f 100644 --- a/tests/phpunit/StorageServerTest.php +++ b/tests/phpunit/StorageServerTest.php @@ -66,7 +66,8 @@ protected function setUp(): void public function testGetFileSystem() { - $filesystem = StorageServer::getFileSystem(); + $rdfAdapter = StorageServer::getRdfAdapter(); + $filesystem = StorageServer::getFileSystem($rdfAdapter); $this->assertInstanceOf('\League\Flysystem\Filesystem', $filesystem); }