Skip to content

Commit 89b023b

Browse files
committed
add grants given to authenticated agents to the user grants.
1 parent a242131 commit 89b023b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/WAC.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,32 @@ private function getUserGrants($resourcePath, $webId) {
148148

149149
// error_log("GET GRANTS for $webId");
150150

151+
// Start with grants that everyone has
151152
$grants = $this->getPublicGrants($resourcePath);
153+
154+
// Then get grants that are valid for any authenticated agent;
155+
$foafAgent = "http://xmlns.com/foaf/0.1/AuthenticatedAgent";
156+
$matching = $graph->resourcesMatching('http://www.w3.org/ns/auth/acl#agentClass');
157+
foreach ($matching as $match) {
158+
$agentClass = $match->get("<http://www.w3.org/ns/auth/acl#agentClass>");
159+
if ($agentClass == $foafAgent) {
160+
$accessTo = $match->get("<http://www.w3.org/ns/auth/acl#accessTo>");
161+
$default = $match->get("<http://www.w3.org/ns/auth/acl#default>");
162+
$modes = $match->all("<http://www.w3.org/ns/auth/acl#mode>");
163+
if ($default) {
164+
foreach ($modes as $mode) {
165+
$grants["default"][$mode->getUri()] = $default->getUri();
166+
}
167+
}
168+
if ($accessTo) {
169+
foreach ($modes as $mode) {
170+
$grants["accessTo"][$mode->getUri()] = $accessTo->getUri();
171+
}
172+
}
173+
}
174+
}
152175

176+
// Then add grants for this specific user;
153177
$matching = $graph->resourcesMatching('http://www.w3.org/ns/auth/acl#agent');
154178
//error_log("MATCHING " . sizeof($matching));
155179
// Find all grants machting our webId;

0 commit comments

Comments
 (0)