Skip to content

Use Nextcloud's request for the base URI of RDF documents (fixes #225) - #228

Open
chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/225-server-uri-overwrite
Open

chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/225-server-uri-overwrite

Conversation

@chefboyrdave21

Copy link
Copy Markdown

Fixes #225.

Problem

StorageController, ProfileController, ContactsController, CalendarController (and the webhook controller) built the base URI for RDF documents from $_SERVER['REQUEST_SCHEME'] and $_SERVER['SERVER_NAME']. Behind a proxy that terminates TLS these describe the internal hop, so relative IRIs in served Turtle resolve to http:// (and to the internal host name, without the public port), whatever overwriteprotocol / overwritehost say.

Fix

A small GetServerUriTrait builds the URI from IRequest::getServerProtocol(), getServerHost() and getRequestUri(), which honour overwriteprotocol, overwritehost and trusted_proxies. This is the approach suggested in #225.

Tests

tests/Unit/Controller/GetServerUriTraitTest.php: scheme/host/path, a non-default port, and that $_SERVER['REQUEST_SCHEME']/SERVER_NAME are ignored.

Verification

Verified on Nextcloud 35.0.2 (PHP 8.5) behind a reverse proxy that terminates TLS, with @inrupt/solid-client-authn-node 5.0.3 / @inrupt/solid-client 4.0.0 and in a headless browser. The unit suite passes in a Nextcloud 35 container. Before: the root .acl served as Turtle has <http://…/storage/> IRIs. After: <https://…/storage/>.

Note: the owner lockout described in #225 also needs pdsinterop/php-solid-auth to advertise the resource's own ACL in Link: rel="acl" (it advertises <.acl> for every resource, which resolves to the container's ACL). I opened a separate PR there.

🤖 Generated with Claude Code

The Storage, Profile, Contacts, Calendar and webhook controllers built the
base URI for RDF documents from $_SERVER['REQUEST_SCHEME'] and
$_SERVER['SERVER_NAME']. Behind a reverse proxy that terminates TLS those
describe the internal hop, so relative IRIs in served Turtle resolved to
http:// (and to the internal host name, without the public port). Clients
that compare IRIs, such as ACL inheritance in Inrupt's solid-client, then
fail to match acl:default against the https container URL.

Take the scheme, host and path from IRequest instead. It honours the
overwriteprotocol, overwritehost and trusted_proxies settings.

Fixes pdsinterop#225

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.

RDF base URL ignores overwriteprotocol behind a TLS-terminating proxy, so served Turtle uses http:// IRIs

1 participant