Repository navigation
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
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>
This branch has not been deployed
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 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 executesSERVICE, 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: aSERVICEon 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 as502from the proxy, and aSERVICEon the store's address as403- both surfaced as500, since the platform cannot read Fuseki's plain-text error body (a separate defect, not fixed here).What
The platform decides every
SERVICEtarget before the query goes out, inSPARQLEndpointImplthrough the newServiceRewriter:<base>sparql): the agent is authorized for that endpoint exactly as aGETof it would be - the dataspace allows public read, or the agent holdsacl:Readon 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 is403for the whole query, naming the endpoint,SILENTor not:SILENTsuppresses a failed call, not the decision whether the call may be made.SERVICE <https://people.example/>):400.400, it cannot be authorized before the query runs.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
AuthorizationFilterintoDataspaceAuthorization, 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
fusekialone 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,SILENTkept, sub-query andNOT EXISTSrewritten, one refusal failing the whole query.URLValidatorTest(+4) forvalidateRemote.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,SILENTor not). Changed:GET-sparql-service-internal.shandPOST-sparql-service-internal.shnow expect400for an internal target, where they acceptedSILENT'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:validateRemotehonoured 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 reachesvalidateRemoteon 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 answer400, the owner'sSERVICEto the admin dataspace answers, an anonymous query is403.🤖 Generated with Claude Code