Skip to content

Commit d8e7329

Browse files
committed
Filter out public authorizations
1 parent 156a3e0 commit d8e7329

File tree

1 file changed

+15
-1
lines changed
  • src/main/java/com/atomgraph/linkeddatahub/resource/acl

1 file changed

+15
-1
lines changed

src/main/java/com/atomgraph/linkeddatahub/resource/acl/Access.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.atomgraph.linkeddatahub.server.security.AgentContext;
3131
import com.atomgraph.linkeddatahub.server.util.AuthorizationParams;
3232
import com.atomgraph.linkeddatahub.vocabulary.ACL;
33+
import com.atomgraph.linkeddatahub.vocabulary.FOAF;
3334
import com.atomgraph.linkeddatahub.vocabulary.LACL;
3435
import com.atomgraph.spinrdf.vocabulary.SPIN;
3536
import jakarta.inject.Inject;
@@ -51,6 +52,7 @@
5152
import org.apache.jena.query.ResultSetRewindable;
5253
import org.apache.jena.rdf.model.Model;
5354
import org.apache.jena.rdf.model.ModelFactory;
55+
import org.apache.jena.rdf.model.ResIterator;
5456
import org.apache.jena.rdf.model.Resource;
5557
import org.apache.jena.rdf.model.ResourceFactory;
5658
import org.apache.jena.vocabulary.RDF;
@@ -126,13 +128,25 @@ public Response get(@QueryParam(QUERY) Query unused,
126128
authPss.setParams(new AuthorizationParams(getApplication().getAdminApplication().getBase(), accessTo, agent).get());
127129

128130
Model authModel = getApplication().getAdminApplication().getService().getSPARQLClient().loadModel(authPss.asQuery());
131+
132+
// filter out authorizations with acl:accessToClass foaf:Agent - all agents already have that access
133+
ResIterator agentClassIter = authModel.listSubjectsWithProperty(ACL.agentClass, FOAF.Agent);
134+
try
135+
{
136+
agentClassIter.toList().forEach((auth) -> authModel.removeAll(auth, null, null));
137+
}
138+
finally
139+
{
140+
agentClassIter.close();
141+
}
142+
129143
// special case where the agent is the owner of the requested document - automatically grant acl:Read/acl:Append/acl:Write access
130144
if (isOwner(accessTo, agent))
131145
{
132146
log.debug("Agent <{}> is the owner of <{}>, granting acl:Read/acl:Append/acl:Write access", agent, accessTo);
133147
authModel.add(createOwnerAuthorization(accessTo, agent).getModel());
134148
}
135-
149+
136150
return getResponseBuilder(authModel).build();
137151
}
138152
finally

0 commit comments

Comments
 (0)