Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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: 2 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ jobs:
fail-fast: false
matrix:
php:
- '8.0' # from 2020-11 to 2022-11 (2023-11)
- '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'
Comment thread
ylebre marked this conversation as resolved.
Resolved
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -118,10 +116,8 @@ jobs:
fail-fast: false
matrix:
php:
- '8.0' # from 2020-11 to 2022-11 (2023-11)
- '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'
steps:
- uses: actions/checkout@v4
- uses: docker://pipelinecomponents/php-codesniffer
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"license": "MIT",
"name": "pdsinterop/solid-auth",
"require": {
"php": "^8.0",
"php": "^8.3",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"laminas/laminas-diactoros": "^2.8",
"laminas/laminas-diactoros": "^3",
Comment thread
ylebre marked this conversation as resolved.
Resolved
"lcobucci/jwt": "^4.1",
"league/oauth2-server": "^8.5.5",
"web-token/jwt-core": "^2.2"
Expand Down
25 changes: 15 additions & 10 deletions src/WAC.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

class WAC {
private $filesystem;
private $adapter;
private $baseUrl;
private $basePath;

public function __construct($filesystem) {
public function __construct($filesystem, $adapter) {
$this->filesystem = $filesystem;
$this->adapter = $adapter;
$this->baseUrl = '';
$this->basePath = '';
}
Expand All @@ -22,8 +24,8 @@ public function setBaseUrl($url) {
}

public function addWACHeaders($request, $response, $webId) {
$currentFormat = $this->filesystem->getAdapter()->getFormat(); // keep the format so we can put it back later. prevents the acl file from being converted;
$this->filesystem->getAdapter()->setFormat('');
$currentFormat = $this->adapter->getFormat(); // keep the format so we can put it back later. prevents the acl file from being converted;
$this->adapter->setFormat('');
$uri = $request->getUri();
$userGrants = $this->getWACGrants($this->getUserGrants($uri, $webId), $uri);
$publicGrants = $this->getWACGrants($this->getPublicGrants($uri), $uri);
Expand All @@ -38,7 +40,7 @@ public function addWACHeaders($request, $response, $webId) {

$response = $response->withAddedHeader("Link", '<.acl>; rel="acl"');
$response = $response->withHeader("WAC-Allow", implode(",", $wacHeaders));
$this->filesystem->getAdapter()->setFormat($currentFormat);
$this->adapter->setFormat($currentFormat);
return $response;
}

Expand Down Expand Up @@ -155,6 +157,7 @@ private function getPublicGrants($resourceUri) {
}

$acl = $this->filesystem->read($aclPath);
$acl .= "\n"; // Fix for sweetrdf not handling files that do not end with a newline

$graph = new \EasyRdf\Graph();

Expand Down Expand Up @@ -193,6 +196,7 @@ private function getUserGrants($resourceUri, $webId) {
return array();
}
$acl = $this->filesystem->read($aclPath);
$acl .= "\n"; // Fix for sweetrdf not handling files that do not end with a newline

$graph = new \EasyRdf\Graph();
$graph->parse($acl, Format::TURTLE, $this->getAclBase($aclPath));
Expand Down Expand Up @@ -257,6 +261,7 @@ private function getOriginGrants($resourceUri, $origin) {
return array();
}
$acl = $this->filesystem->read($aclPath);
$acl .= "\n"; // Fix for sweetrdf not handling files that do not end with a newline

$graph = new \EasyRdf\Graph();
$graph->parse($acl, Format::TURTLE, $this->getAclBase($aclPath));
Expand Down Expand Up @@ -307,7 +312,7 @@ private function getAclPath($path) {

foreach ($aclOptions as $aclPath) {
if (
$this->filesystem->has($aclPath) && $this->filesystem->read($aclPath) !== false
$this->filesystem->fileExists($aclPath) && $this->filesystem->read($aclPath) !== false
) {
return $aclPath;
}
Expand All @@ -323,7 +328,7 @@ private function normalizePath($path) {
}
private function getParentAcl($path) {
// error_log("GET PARENT ACL $path");
if ($this->filesystem->has($this->normalizePath($path.'/.acl'))) {
if ($this->filesystem->fileExists($this->normalizePath($path.'/.acl'))) {
// error_log("CHECKING ACL FILE ON $path/.acl");
return $this->normalizePath($path . "/.acl");
}
Expand Down Expand Up @@ -401,7 +406,7 @@ public function getRequestedGrants($request) {
);
break;
case "PUT":
if ($this->filesystem->has($path)) {
if ($this->filesystem->fileExists($path)) {
return array(
array(
"type" => "resource",
Expand Down Expand Up @@ -438,7 +443,7 @@ public function getRequestedGrants($request) {
break;
case "PATCH";
$grants = array();
if (!$this->filesystem->has($path)) {
if (!$this->filesystem->fileExists($path)) {
$grants[] = array(
"type" => "parent",
"grants" => array(
Expand All @@ -465,7 +470,7 @@ public function getRequestedGrants($request) {
);
}
if (strstr($body, "inserts")) {
if ($this->filesystem->has($path)) {
if ($this->filesystem->fileExists($path)) {
$grants[] = array(
"type" => "resource",
"grants" => array(
Expand Down Expand Up @@ -507,7 +512,7 @@ private function getParentUri($uri) {
$localPath = str_replace($this->basePath, '', $parentPath);
if ($localPath == "/") {
return $uri->withPath($parentPath);
} elseif ($this->filesystem->has($localPath)) {
} elseif ($this->filesystem->fileExists($localPath)) {
return $uri->withPath($parentPath);
} else {
return $this->getParentUri($uri->withPath($parentPath));
Expand Down
Loading