Skip to content

Commit d4da6c5

Browse files
committed
Fix bug caused by passing an array as a string in Resource controller.
1 parent c5c5e76 commit d4da6c5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Controller/ResourceController.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,26 @@ final public function __invoke(Request $request, array $args) : Response
4141
try {
4242
$webId = $this->DPop->getWebId($request);
4343
} catch(\Exception $e) {
44-
return $this->server->getResponse()->withStatus(409, "Invalid token");
44+
return $this->server->getResponse()->withStatus(409, 'Invalid token');
4545
}
4646

47-
$origin = $request->getHeader("Origin");
48-
if (!$this->WAC->isAllowed($request, $webId, $origin)) {
49-
return $this->server->getResponse()->withStatus(403, "Access denied");
50-
}
47+
$origins = $request->getHeader('Origin');
48+
49+
$isAllowed = false;
50+
foreach ($origins as $origin) {
51+
if ($this->WAC->isAllowed($request, $webId, $origin)) {
52+
$isAllowed = true;
53+
break;
54+
}
55+
}
56+
57+
if (! $isAllowed) {
58+
return $this->server->getResponse()->withStatus(403, 'Access denied');
59+
}
5160

5261
$response = $this->server->respondToRequest($request);
53-
$response = $this->WAC->addWACHeaders($request, $response, $webId);
54-
55-
return $response;
62+
63+
return $this->WAC->addWACHeaders($request, $response, $webId);
5664
}
5765

5866
private function generateDefaultAcl() {

0 commit comments

Comments
 (0)