Skip to content

Advertise the resource's own ACL in the Link rel="acl" header - #70

Open
chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/wac-acl-link-per-resource
Open

chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/wac-acl-link-per-resource

Conversation

@chefboyrdave21

Copy link
Copy Markdown

Problem

WAC::addWACHeaders() adds Link: <.acl>; rel="acl" to every response. Clients resolve that reference against the resource URI, so for /foo/bar.ttl it points at /foo/.acl, the ACL of the container, not /foo/bar.ttl.acl.

Clients that change the access to one resource write to the advertised ACL. Inrupt's solid-client (universalAccess.setAgentAccess) builds a new ACL with only the requested rule and saves it to the advertised URL. With the current header that replaces the rules of the whole container, and the owner loses access to everything in it. This is the lockout reported in pdsinterop/solid-nextcloud#225.

Fix

Advertise <name.acl> for a resource and <.acl> for a container, as WAC's ACL resource discovery requires (the ACL resource does not have to exist yet). The logic is in a small public getAclLinkTarget() so it can be tested on its own.

Tests

New tests/unit/WACTest.php (14 cases: root and nested containers, resources at the root and nested, a percent-encoded name, ACL resources themselves), including that the advertised reference resolves to the resource's own ACL. On PHP 8.4 all of them pass. The existing DPOPTest errors and failure (5 errors, 1 failure) are the same on main without this change.

On PHP 8.5 the first test that loads WAC errors because of the deprecated case "PATCH";; that is fixed in a separate small PR.

Verification

In solid-nextcloud on Nextcloud 35 (with the server URI fix from pdsinterop/solid-nextcloud#228): HEAD /…/private/note.ttl now gives Link: <note.ttl.acl>; rel="acl". setAgentAccess(note.ttl, bob, {read: true}) writes note.ttl.acl with the owner's inherited rules plus bob's, and the owner keeps access. Before: it wrote private/.acl with only bob's rule and the owner got 403 on the whole container.

🤖 Generated with Claude Code

addWACHeaders() added `Link: <.acl>; rel="acl"` to every response. A
client resolves that reference against the resource URI, so for
/foo/bar.ttl it points at /foo/.acl, the ACL of the container, instead of
/foo/bar.ttl.acl.

Clients that change access to a single resource write to the advertised
ACL. Inrupt's solid-client (universalAccess.setAgentAccess) does exactly
that: it builds a new ACL with only the requested rule and saves it to
the advertised URL. With the old header that replaced the rules for the
whole container, so the owner lost access to everything in it.

Advertise `<name.acl>` for a resource and `<.acl>` for a container, as
WAC's ACL resource discovery requires. The ACL resource does not have to
exist yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant