Skip to content

Commit bbc4661

Browse files
committed
pass allowed clients to origin check
1 parent 1fcaebb commit bbc4661

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/WAC.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function addWACHeaders($request, $response, $webId) {
4646
* see: https://github.com/solid/web-access-control-spec
4747
*/
4848

49-
public function isAllowed($request, $webId, $origin=false) {
49+
public function isAllowed($request, $webId, $origin=false, $allowedClients=[]) {
5050
$requestedGrants = $this->getRequestedGrants($request);
5151
$uri = $request->getUri();
5252
$parentUri = $this->getParentUri($uri);
@@ -60,7 +60,7 @@ public function isAllowed($request, $webId, $origin=false) {
6060
if (!$this->isUserGranted($requestedGrant['grants'], $uri, $webId)) {
6161
return false;
6262
}
63-
if (!$this->isOriginGranted($requestedGrant['grants'], $uri, $origin)) {
63+
if (!$this->isOriginGranted($requestedGrant['grants'], $uri, $origin, $allowedClients)) {
6464
return false;
6565
}
6666
break;
@@ -71,7 +71,7 @@ public function isAllowed($request, $webId, $origin=false) {
7171
if (!$this->isUserGranted($requestedGrant['grants'], $parentUri, $webId)) {
7272
return false;
7373
}
74-
if (!$this->isOriginGranted($requestedGrant['grants'], $parentUri, $origin)) {
74+
if (!$this->isOriginGranted($requestedGrant['grants'], $parentUri, $origin, $allowedClients)) {
7575
return false;
7676
}
7777
break;
@@ -91,7 +91,6 @@ private function checkGrants($requestedGrants, $uri, $grants) {
9191
if (!$requestedGrants) {
9292
return true;
9393
}
94-
$path = $this->getPathFromUri($uri);
9594
if (is_array($grants)) {
9695
foreach ($requestedGrants as $requestedGrant) {
9796
if ($grants['accessTo'] && $grants['accessTo'][$requestedGrant] && $this->arePathsEqual($grants['accessTo'][$requestedGrant], $uri)) {
@@ -121,11 +120,11 @@ private function isUserGranted($requestedGrants, $uri, $webId) {
121120
return $this->checkGrants($requestedGrants, $uri, $grants);
122121
}
123122

124-
private function isOriginGranted($requestedGrants, $uri, $origin) {
123+
private function isOriginGranted($requestedGrants, $uri, $origin, $allowedClients) {
125124
if (!$origin) {
126125
return true;
127126
}
128-
127+
129128
//error_log("REQUESTED GRANT: " . join(" or ", $requestedGrants) . " on $uri");
130129
$grants = $this->getOriginGrants($uri, $origin);
131130
//error_log("GRANTED GRANTS for origin $origin: " . json_encode($grants));

0 commit comments

Comments
 (0)