Repository navigation
SERVICE on behalf of the asking agent: the platform marks the call, the triplestore's LinkedDataHub module delegates it - #567
Merged
Conversation
… 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>
…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>
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theSERVICEcall 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, fromSPARQLEndpointImpl). Before a query goes to the store, everyhttpsSERVICEIRI getsldh-on-behalf-of(the agent's WebID),ldh-expires(five minutes on) andldh-signature(SHA256withRSAwith the secretary's private key overtarget \n agent \n expires). Any marker a query author wrote is removed first.SERVICE_DELEGATIONturns it on (defaulttruein the compose file).The store delegates the call (
fuseki-module/, a Fuseki auto-module in Jena'sSERVICEexecutor 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,SILENTor 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:On-Behalf-Ofnaming the agent, exactly as the Linked Data proxy sends a write to another instance; the target'sWebIDFilterverifies the delegation and its own access control decides;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 newfusekistage -atomgraph/fusekiwith the module in/fuseki/extra/and an entrypoint that puts it on the classpath (the stock entrypoint's-jarreads no other jar) with-Djdk.httpclient.allowRestrictedHeaders=host.atomgraph/fusekiitself is untouched and stays generic. The compose file builds the stage and gives it the secretary's keystore and the server certificate (asweb-algebraalready holds the secretary's key to act for users).release.ymlbuilds and publishes it asatomgraph/linkeddatahub-fusekibeside the platform and the SEF compiler - not published until a release.Also: a
SERVICEtarget that is internal or loopback, or a variable, is400before the query goes out, in every deployment mode (URLValidator.validateRemote; the test stacks run withALLOW_INTERNAL_URLS=true); a dataspace named by anything but its endpoint is400.Tested
fuseki-module: 15 tests against stub TLS endpoints built from the JDK, with keystores made bykeytoolper run: an endpoint that asks receives the secretary's certificate,On-Behalf-Of, the originalHostand 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.ServiceTargetsTest(11: marks and signature, plainhttpand 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).fusekiimage built locally and started: the module loads.GET-sparql-service-dataspace.sh(the owner'sSERVICEto 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:SILENTgives 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.shexpect400.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
SERVICE; bulkSERVICE(jena-serviceenhancer) will matter for large joins.SERVICEleg surfaces from the platform as500: Core's remote endpoint accessor reads the store's error body without checking the status. Separate defect.🤖 Generated with Claude Code