Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
33 changes: 25 additions & 8 deletions lib/ProfileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions lib/Routes/SolidStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ 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");
StorageServer::respond($response);
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);
Expand Down
7 changes: 4 additions & 3 deletions lib/Routes/SolidUserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 25 additions & 8 deletions lib/StorageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Pdsinterop\PhpSolid\Util;
use Pdsinterop\PhpSolid\Db;


class StorageServer extends Server
{
public static function getStorage($storageId)
Expand Down Expand Up @@ -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)) {
Expand All @@ -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();
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/StorageServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading