Skip to content

ACL relative URI resolution: ./#me not matching authenticated WebID #64

Closed

Description

@melvincarvalho

Description

When using a relative URI like ./#me or /#me in an ACL file to reference the owner's WebID, it doesn't seem to match the authenticated user's WebID during authorization checks.

Steps to Reproduce

  1. Set up JSS with WebID at https://example.com/#me
  2. Create root ACL (.acl) with relative agent:
{
  "@context": {
    "acl": "http://www.w3.org/ns/auth/acl#",
    "foaf": "http://xmlns.com/foaf/0.1/"
  },
  "@graph": [
    {
      "@id": "#owner",
      "@type": "acl:Authorization",
      "acl:agent": { "@id": "./#me" },
      "acl:accessTo": { "@id": "./" },
      "acl:default": { "@id": "./" },
      "acl:mode": [
        { "@id": "acl:Read" },
        { "@id": "acl:Write" },
        { "@id": "acl:Control" }
      ]
    }
  ]
}
  1. Authenticate as https://example.com/#me
  2. Try to PUT a resource

Expected Behavior

./#me in /.acl should resolve to https://example.com/#me and match the authenticated user, granting write access.

Actual Behavior

Returns 403 Forbidden. The wac-allow header shows user="read" (from public ACL) instead of including write permissions.

Workaround

Using the absolute URI works:

"acl:agent": { "@id": "https://example.com/#me" }

Environment

  • JSS version: 0.0.72
  • Node.js: v22.21.1

Notes

This may be a URI resolution issue where the relative reference isn't being resolved against the ACL document's base URI before comparing with the authenticated WebID.

Activity

  1. melvincarvalho commented on Jan 7, 2026

    @melvincarvalho
    ContributorAuthor

    Root Cause

    Found the bug in src/wac/parser.js. In parseAuthorization(), accessTo and default URIs are resolved against the base URL, but agents were not being resolved:

    // These were resolved:
    auth.accessTo = parseUriArray(...).map(uri => resolveUri(uri, baseUrl));
    auth.default = parseUriArray(...).map(uri => resolveUri(uri, baseUrl));
    
    // But agents were NOT resolved:
    auth.agents = parseUriArray(node['acl:agent'] || node['agent']);  // Bug\!

    Fix

    One-line fix - resolve agent URIs against the ACL URL:

    // Parse agents (WebIDs can be relative too) - resolve against ACL URL
    auth.agents = parseUriArray(node['acl:agent'] || node['agent'])
      .map(uri => resolveUri(uri, aclUrl));

    Note: We resolve against aclUrl (not baseUrl) because ./#me in /.acl should resolve to https://example.com/#me.

    Status

    Fix applied to melvincarvalho.com - can create a PR if this looks good.

  2. added a commit that references this issue on Jan 7, 2026
    bdbbbb7
  3. bourgeoa commented on Jan 7, 2026

    @bourgeoa

    @melvincarvalho
    Are you sure that your .jsonld is correct.
    Why not use "acl:agent": { "@id": "/#me" }, without . this is what I would have in text/turtle

  4. melvincarvalho commented on Jan 7, 2026

    @melvincarvalho
    ContributorAuthor

    Thanks for taking a look! 🙏

    You raise a good point. The . in ./#me is meant to make it relative to the current document (so ./ resolves to the ACL file's directory), but you're right that /#me would be more consistent with the Turtle convention.

    I'll double-check the JSON-LD context handling and update if needed. Appreciate the review!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions