Skip to content

WAC returns 403 for path-based pod access when subdomains enabled #144

Closed

Description

@melvincarvalho

Bug

With subdomains: true and baseDomain: "example.com", accessing a pod resource via path-based URL (example.com/alice/public/file.ttl) returns 403 Forbidden even when the ACL grants public Read access.

Accessing via subdomain (alice.example.com/public/file.ttl) works correctly.

Cause

In src/auth/middleware.js line 59, the WAC middleware constructs the resource URL from the request hostname:

const resourceUrl = `${request.protocol}://${request.hostname}${urlPath}`;

For path-based access on the main domain, this produces:

  • https://example.com/alice/public/file.ttl

But ACLs (generated during pod creation) reference subdomain-form URLs:

  • acl:accessTo <https://alice.example.com/public/>
  • acl:default <https://alice.example.com/public/>

The WAC checker compares the path-based URL against the subdomain-based ACL and finds no match, denying access.

Fix

Normalize path-based URLs to subdomain form when subdomains are enabled:

let resourceUrl = `${request.protocol}://${request.hostname}${urlPath}`;
if (request.subdomainsEnabled && request.baseDomain && 
    request.hostname === request.baseDomain && !request.podName) {
  const pathMatch = urlPath.match(/^\/([^\/]+)(\/.*)$/);
  if (pathMatch) {
    resourceUrl = `${request.protocol}://${pathMatch[1]}.${request.baseDomain}${pathMatch[2]}`;
  }
}

Note: The same fix should be applied to the parent container URL rewrite (line 78) for PUT/POST/PATCH on non-existent resources.

Steps to reproduce

  1. Enable subdomains: true and baseDomain: "example.com" in config
  2. Create a pod (e.g., alice) — ACLs are generated with subdomain URLs
  3. Add a file to alice/public/ (which has public Read ACL)
  4. Access https://example.com/alice/public/file.ttl — 403 Forbidden
  5. Access https://alice.example.com/public/file.ttl — 200 OK

Activity

  1. added a commit that references this issue on Mar 3, 2026
    59118a9
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