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
8 changes: 4 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ 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)
- '8.5' # from 2025-11 to 2027-12 (2029-12)
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -138,9 +138,9 @@ 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)
- '8.5' # from 2025-11 to 2027-12 (2029-12)
steps:
- uses: actions/checkout@v4
- uses: docker://pipelinecomponents/php-codesniffer
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
}
],
"require": {
"pdsinterop/solid-auth": "v0.14.2",
"pdsinterop/solid-crud": "v0.8.5",
"pdsinterop/solid-auth": "dev-fix/flysystem-3-mpss",
"pdsinterop/solid-crud": "dev-fix/flysystem-3-mpss",
"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"
"phrity/websocket": "^3.5",
"league/mime-type-detection": "^1.17",
"league/flysystem-local": "^3.35"
},
"require-dev": {
"phpunit/phpunit": "^9 || ^10 || ^11 || ^12",
"phpstan/phpstan": "^2.1"
},
"minimum-stability": "dev",
"config": {
"policy": {
"advisories": {
Expand Down
38 changes: 30 additions & 8 deletions lib/ProfileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@

class ProfileServer extends Server
{
public static function getFileSystem()
public static function getMimeDetector()
{
$extensionMap = new \League\MimeTypeDetection\OverridingExtensionToMimeTypeMap(
new \League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap(),
[
'acl' => 'text/turtle'
]
);

$mimeTypeDetector = new \League\MimeTypeDetection\FinfoMimeTypeDetector(
'',
$extensionMap
);
return $mimeTypeDetector;
}

public static function getRdfAdapter()
{
$profileId = self::getProfileId();

Expand All @@ -17,10 +33,15 @@ 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,
null, // visibilityConverter
LOCK_EX, // writeFlags
0002, // disallow links
self::getMimeDetector()
);

$graph = new \EasyRdf\Graph();
Expand All @@ -29,12 +50,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 +114,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
37 changes: 29 additions & 8 deletions lib/StorageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,23 @@ public static function getOwnerWebId()
return false;
}

public static function getFileSystem()
public static function getMimeDetector()
{
$extensionMap = new \League\MimeTypeDetection\OverridingExtensionToMimeTypeMap(
new \League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap(),
[
'acl' => 'text/turtle'
]
);

$mimeTypeDetector = new \League\MimeTypeDetection\FinfoMimeTypeDetector(
'',
$extensionMap
);
return $mimeTypeDetector;
}

public static function getRdfAdapter()
{
$storageId = self::getStorageId();
if (!self::storageIdExists($storageId)) {
Expand All @@ -114,9 +130,13 @@ 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/",
null, // visibilityConverter
LOCK_EX, // writeFlags
0002, // disallow links
self::getMimeDetector()
);

$graph = new \EasyRdf\Graph();
Expand All @@ -125,12 +145,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 +194,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