Skip to content

SERVICE on behalf of the asking agent: the platform marks the call, the triplestore's LinkedDataHub module delegates it - #567

Merged
namedgraph merged 15 commits into
developfrom
federated-dataspaces
Nov 26, 2026
Merged

namedgraph merged 15 commits into
developfrom
federated-dataspaces

Conversation

@namedgraph

@namedgraph namedgraph commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Why

A query asked at one dataspace's endpoint can name another - of this deployment or of another LinkedDataHub - with SERVICE <https://people.example/sparql> { … }. It never worked: the triplestore makes the SERVICE call and knows nobody, so the call arrived anonymous and the target's endpoint, which guards itself, refused it (and the store's proxy refused the deployment's own addresses before that). Each dataspace keeps deciding its own access; what was missing is the asking agent's identity on the hop the store makes. Design and discussion: #568.

The first version of this PR had the platform at the asking side apply the target's ACL and send the store straight to the target's dataset. That was withdrawn: the asking side must not guard another dataspace's door, and it could not work across deployments.

What

The platform marks the call (ServiceTargets, ServiceDelegation, from SPARQLEndpointImpl). Before a query goes to the store, every https SERVICE IRI gets ldh-on-behalf-of (the agent's WebID), ldh-expires (five minutes on) and ldh-signature (SHA256withRSA with the secretary's private key over target \n agent \n expires). Any marker a query author wrote is removed first. SERVICE_DELEGATION turns it on (default true in the compose file).

The store delegates the call (fuseki-module/, a Fuseki auto-module in Jena's SERVICE executor chain - public extension points, no patching). For a marked IRI it checks the signature against the secretary's certificate (a forged, partial or expired marker fails the query, SILENT or not), removes the marker, and asks the target by an anonymous TLS handshake - remembered per origin for ten minutes - whether it wants a client certificate:

  • if it does, the call is made as the secretary with On-Behalf-Of naming the agent, exactly as the Linked Data proxy sends a write to another instance; the target's WebIDFilter verifies the delegation and its own access control decides;
  • if it does not (a public SPARQL service), the call stays anonymous: the agent is not announced to an endpoint that does not ask who is calling.

Own origins (the deployment's host and subdomains) are reached through nginx's client-certificate listener under their own name, trusting the deployment's server certificate, as the platform's own client reaches them; anything else as named, through the egress proxy. The keystore is read at the first marked call (the platform creates it and starts after the store). Without a keystore configured the module drops every marker, so a marked query never sends the agent's WebID or signature on.

The image: the Dockerfile's new fuseki stage - atomgraph/fuseki with the module in /fuseki/extra/ and an entrypoint that puts it on the classpath (the stock entrypoint's -jar reads no other jar) with -Djdk.httpclient.allowRestrictedHeaders=host. atomgraph/fuseki itself is untouched and stays generic. The compose file builds the stage and gives it the secretary's keystore and the server certificate (as web-algebra already holds the secretary's key to act for users). release.yml builds and publishes it as atomgraph/linkeddatahub-fuseki beside the platform and the SEF compiler - not published until a release.

Also: a SERVICE target that is internal or loopback, or a variable, is 400 before the query goes out, in every deployment mode (URLValidator.validateRemote; the test stacks run with ALLOW_INTERNAL_URLS=true); a dataspace named by anything but its endpoint is 400.

Tested

  • fuseki-module: 15 tests against stub TLS endpoints built from the JDK, with keystores made by keytool per run: an endpoint that asks receives the secretary's certificate, On-Behalf-Of, the original Host and no marker; one that does not ask sees neither certificate nor agent; forged, expired and partial markers fail the query; a keystore not there yet fails the call by name and is read again on the next.
  • Platform: ServiceTargetsTest (11: marks and signature, plain http and anonymous queries unmarked, an author's marker replaced, refusals, nested patterns, the shared test vector), URLValidatorTest (+4); the whole suite, 663 tests, passes. The formal models' tracking checks pass (the ACL code is unchanged).
  • The fuseki image built locally and started: the module loads.
  • HTTP suite, new: GET-sparql-service-dataspace.sh (the owner's SERVICE to the admin dataspace answers with its root document), GET-sparql-service-dataspace-refused.sh (a signed-up agent's is refused at the admin door: SILENT gives nothing, without it the query fails), federation/SERVICE-cross-instance-delegated.sh (A's owner reads B's endpoint, which answers authenticated agents only). Changed: the two *-service-internal.sh expect 400.

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 builds the stack with up --build, so it runs the new stage.

Open

  • Each delegated call is a TLS round trip and an access decision at the target, once per solution of what precedes the SERVICE; bulk SERVICE (jena-serviceenhancer) will matter for large joins.
  • A refused SERVICE leg surfaces from the platform as 500: Core's remote endpoint accessor reads the store's error body without checking the status. Separate defect.
  • Marker replay: a marker is valid for five minutes for that target and agent; the store's query log shows it. Binding it to the outer query would close that and needs the store to see the outer query in the executor.

🤖 Generated with Claude Code

namedgraph and others added 8 commits November 2, 2026 12:12
… 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>
…ce's endpoint is left to its own door

The first version had the platform handling the outer query read the other dataspace's ACL and send Fuseki straight to
that dataspace's store. That is the asking side doing the target's guarding: each dataspace guards its own endpoint,
so the identity has to reach that endpoint - delegated through Fuseki, as the Linked Data proxy delegates writes with
On-Behalf-Of - and the target's own AuthorizationFilter must decide. That is designed in #568 and not built.

What stands: ServiceTargets refuses an internal or loopback SERVICE target, or a variable, with 400 before the query
goes out, whether or not the deployment allows internal URLs; a dataspace named by anything but its endpoint is 400
too. DataspaceAuthorization is gone and AuthorizationFilter is as it was; Fuseki's proxy exemption is gone; the formal
models' notes are gone with the code they described.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@namedgraph namedgraph changed the title A query federates across the dataspaces of one deployment: SERVICE on a dataspace's endpoint is authorized for the agent and reaches its store A SERVICE target that is internal, loopback or a variable is refused before the query goes to the store Nov 22, 2026
namedgraph and others added 2 commits November 22, 2026 18:59
…he triplestore's LinkedDataHub module delegates it

A query asked at one dataspace's endpoint that names another - of this deployment or another LinkedDataHub - with
SERVICE reached it anonymously: the triplestore makes the call and knows nobody, so the target's door, which guards it,
refused. Each dataspace keeps guarding its own endpoint; what was missing is the asking agent's identity on that hop.

The platform (ServiceTargets, from SPARQLEndpointImpl) marks each https SERVICE IRI with the agent's WebID, an expiry
and the secretary's signature (ServiceDelegation), removing any marker a query author wrote; SERVICE_DELEGATION turns
it on, by default in the compose file. The triplestore's new module (fuseki/, a Fuseki auto-module in Jena's SERVICE
chain) checks the signature against the secretary's certificate - a forged, partial or expired marker fails the query,
SILENT or not - and asks the target by an anonymous handshake whether it wants a client certificate: if it does, the
call is made as the secretary with On-Behalf-Of naming the agent, as the Linked Data proxy sends a write, and the
target's own access control decides; if not, it stays anonymous. Own origins are reached through nginx's
client-certificate listener under their own name, as the platform reaches them.

The image: the Dockerfile's fuseki stage, atomgraph/fuseki with the module on the classpath (its entrypoint's -jar reads
no other jar); compose builds it; release publishes it as atomgraph/linkeddatahub-fuseki with the platform.

Tests: the module's 15 (stub TLS endpoints that ask and do not ask, forged, expired and partial markers, a keystore not
there yet), ServiceTargetsTest (11), the platform's suite (663). HTTP: an owner's SERVICE to the admin dataspace answers,
a signed-up agent's is refused at that door, and A's owner reads B's endpoint across instances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a folder, which the repository ignores

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@namedgraph namedgraph changed the title A SERVICE target that is internal, loopback or a variable is refused before the query goes to the store SERVICE on behalf of the asking agent: the platform marks the call, the triplestore's LinkedDataHub module delegates it Nov 22, 2026
namedgraph and others added 4 commits November 22, 2026 21:15
…ate, as its platform and web-algebra do

The three delegation tests failed on CI: the store's module looked for the secretary's keystore where the base compose
file mounts it (./ssl/secretary), and the suite's override keeps the suite's own in ./tests/http/ssl for every other
service. The marker itself reached the module and was parsed (the store's log names the call and the agent).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ption, not only its path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its internal address

federation/SERVICE-cross-instance-delegated.sh failed on CI with 400 before the query reached
the store: B, https://remote.localhost:4443/, resolves to an internal address inside A's
platform, and validateRemote refuses those regardless of ALLOW_INTERNAL_URLS. Such a target is
reached through the deployment's front door (the store's module routes the deployment's host
and its subdomains to nginx, as ClientUriRewriteFilter does for the platform's own requests),
never at that address, so it is not checked by it. A plain http target on the domain is still
checked: the store would call it itself.

ServiceTargetsTest +2, written before the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
#	src/main/java/com/atomgraph/linkeddatahub/server/model/impl/SPARQLEndpointImpl.java
@namedgraph
namedgraph changed the base branch from master to develop November 26, 2026 17:12
@namedgraph
namedgraph merged commit 36952fa into develop Nov 26, 2026
5 checks passed
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