Skip to content

A query federates across the dataspaces of one deployment: SERVICE on a dataspace's endpoint is authorized for the agent and reaches its store - #567

Open
namedgraph wants to merge 4 commits into
masterfrom
federated-dataspaces
Open

namedgraph wants to merge 4 commits into
masterfrom
federated-dataspaces

Conversation

@namedgraph

@namedgraph namedgraph commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Why

A question that spans dataspaces - people in one, issues in another, messages in a third - has to federate: SERVICE <https://people.example/sparql> { … } from the dataspace it is asked in. That did not work. The triplestore executes SERVICE, knows no agent, and its outbound calls go through the egress proxy, which refuses the deployment's own addresses. That refusal is deliberate (docker-compose.yml: a SERVICE on a sibling dataset's own address would read what the ACL never granted), but it left no way to federate between dataspaces at all: on a stack, SERVICE <https://people.localhost:4444/sparql> ends as 502 from the proxy, and a SERVICE on the store's address as 403 - both surfaced as 500, since the platform cannot read Fuseki's plain-text error body (a separate defect, not fixed here).

What

The platform decides every SERVICE target before the query goes out, in SPARQLEndpointImpl through the new ServiceRewriter:

  • A dataspace of this deployment, named by its public SPARQL endpoint (<base>sparql): the agent is authorized for that endpoint exactly as a GET of it would be - the dataspace allows public read, or the agent holds acl:Read on the endpoint in that dataspace's admin store - and the clause is rewritten to the dataspace's store (sd:endpoint, http://fuseki:3030/<name>.end-user/), where the triplestore reaches it directly. A refusal is 403 for the whole query, naming the endpoint, SILENT or not: SILENT suppresses a failed call, not the decision whether the call may be made.
  • A dataspace named by anything but its endpoint (SERVICE <https://people.example/>): 400.
  • A variable target: 400, it cannot be authorized before the query runs.
  • Anything else: validated as a remote address (URLValidator.validateRemote, which refuses loopback too - the triplestore's JVM is what loopback names there) and left as it is, so public federation works as before, through the proxy.

The access control decision moves out of AuthorizationFilter into DataspaceAuthorization, parametrized by the dataspace; the filter delegates to it for the request's dataspace, with the same queries and the same results.

Fuseki's JVM exempts the host fuseki alone from the proxy (-Dhttp.nonProxyHosts=fuseki): the platform is its only client and admits no other internal target.

Tested

  • ServiceRewriterTest (12): authorized, refused and public-read dataspaces, a dataspace not named by its endpoint, a variable, an internal and a loopback target, a public target left alone, SILENT kept, sub-query and NOT EXISTS rewritten, one refusal failing the whole query.
  • URLValidatorTest (+4) for validateRemote.
  • The whole unit suite: 652 tests, 0 failures.
  • HTTP suite, new: GET-sparql-service-dataspace.sh (the owner reads the admin dataspace's root document through the end-user endpoint), GET-sparql-service-dataspace-403.sh (a signed-up agent is refused, SILENT or not). Changed: GET-sparql-service-internal.sh and POST-sparql-service-internal.sh now expect 400 for an internal target, where they accepted SILENT's empty result.

Not run here: the HTTP suite against a stack (this machine's one stack is busy with another product's end-to-end run); CI runs it.

Note

Federation of one deployment's dataspaces is what OpsGraph needs (its dataspaces are domains: people, issues, messages); its stack takes the same Fuseki setting.

Found while testing on a stack (second commit)

The test stacks run with ALLOW_INTERNAL_URLS=true, and with Fuseki now reaching itself, SERVICE SILENT <http://fuseki:3030/admin/> answered the admin store's graph: validateRemote honoured the allowance. It no longer does. The allowance is for the platform dereferencing its own documents and WebIDs on an internal address; a query's targets that are the platform's own are matched as dataspaces before any validation, so what reaches validateRemote on an internal address is a store or a service of the deployment, refused in every mode. Confirmed on the stack after the fix: the internal, loopback, non-endpoint and variable targets answer 400, the owner's SERVICE to the admin dataspace answers, an anonymous query is 403.

🤖 Generated with Claude Code

namedgraph and others added 4 commits November 21, 2026 10:09
… a dataspace's endpoint is authorized for the agent and reaches its store

A SERVICE clause naming another dataspace's public SPARQL endpoint used to fail: the triplestore executes it, knows no
agent, and its outbound calls go through the egress proxy, which refuses the deployment's own addresses - on purpose,
since a sibling dataset read that way would bypass the ACL. So a question over people, issues and messages, each in
its own dataspace, could not be asked.

The platform now decides each SERVICE target before the query goes out (ServiceRewriter, from SPARQLEndpointImpl): a
dataspace of the deployment, named by its endpoint, is authorized for the agent as a GET of that endpoint would be -
public read, or acl:Read in that dataspace's admin store (DataspaceAuthorization, the decision AuthorizationFilter
made for the request's dataspace alone, now made for any) - and rewritten to the dataspace's store; a refusal is 403
for the whole query. A dataspace named by anything but its endpoint, a variable target, or any other internal or
loopback address is 400. Public targets are left as they are. Fuseki's JVM therefore exempts the host fuseki alone
from the proxy; the platform is its only client and admits no other internal target.

Unit tests: ServiceRewriterTest (12), URLValidatorTest (+4). HTTP tests: a SERVICE to the admin dataspace answers
the owner and refuses a signed-up agent with 403; an internal target is 400 (the two service-internal tests, which
expected SILENT's empty result before).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…he model tracks; its definitions stand

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ataspaceAuthorization's; the model stands

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…yment allows internal URLs

Found on a stack running with ALLOW_INTERNAL_URLS=true (the test stacks do): with Fuseki now reaching itself for
rewritten SERVICE clauses, SERVICE SILENT <http://fuseki:3030/admin/> answered the admin store's graph, since
validateRemote honoured the allowance. The allowance is for the platform dereferencing its own documents and WebIDs
on an internal address; a query's targets that are the platform's own are matched as dataspaces before any
validation, so what reaches validateRemote on an internal address is a store or a service of the deployment, which no
mode may read past the ACL. URLValidatorTest covers it.

Co-Authored-By: Claude Fable 5.1 <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