Repository navigation
feat(jsonld): filter the Entrypoint context per caller (0.11.0) - #28
Merged
Merged
Conversation
/api/contexts/Entrypoint now names exactly the resources whose link the JSON-LD entrypoint /api shows the same caller, plus @vocab and hydra. A decorator of the JSON-LD context builder takes the allowed keys from the filtered entrypoint normalizer, so page and context share one decision. It fails closed: without the normalizer, or when it throws, only the base entries remain. Class contexts, Error and ConstraintViolationList stay unfiltered. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The per-caller /api/contexts/Entrypoint now gets Cache-Control: private and Vary: Authorization like the other filtered discovery documents, also under a public cache configuration. Class contexts, Error and ConstraintViolationList keep the headers of API Platform. Kernel tests pin that the ETag of the context belongs to the filtered body. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…the filtered body [*] API Platform computes the ETag from the unfiltered documentation before the filter listener replaces the body, so callers with different documents shared one ETag and a conditional request could confirm foreign content. The listener now recomputes the ETag (xxh3, strong) from the final body whenever the response already carries one; with cache_headers.etag: false none is added. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
README: which JSON-LD context is filtered, which are not and why, cache headers and ETags of the filtered documents. CHANGELOG 0.11.0 with the consumer actions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Summary
The last discovery document of #21 follows the per-caller filter: the JSON-LD context of the entrypoint,
/api/contexts/Entrypoint.EntrypointContextFilter, decoratingapi_platform.jsonld.context_builder):/api/contexts/Entrypoint(with and without.jsonld) contains exactly the resource keys whose link the JSON-LD entrypoint/apishows the same caller, plus@vocabandhydra. The allowed keys come from the filtered JSON-LD entrypoint normalizer, so page and context share one decision and cannot drift apart. Fails closed: without the normalizer, without a request, or when the decision throws, only the base entries remain.Cache-Control: privatewithVary: Authorization, also under a public cache configuration./api/docs.jsonldfrom the unfiltered body before the filter listener replaced it, so callers with different documents shared one ETag. The listener now recomputes it from the final body when the response carries one.0.11.0.No configuration key was added;
discovery.filter_operations_by_security: falserestores API Platform's behaviour.Deliberately unfiltered
The contexts of the resource classes (
/api/contexts/<ShortName>),ErrorandConstraintViolationListkeep API Platform's content and headers and answer 200 also for a class the caller sees in no discovery document: a visible response may embed an object of a hidden class, and a JSON-LD client then needs that context. A class context therefore still names the property names of its class and reveals its existence.Observable break
The Entrypoint context is smaller than API Platform's for every caller, also for one with all rights: resources without a link on
/apihave no key, and neither haveerrorandconstraintViolation. See the consumer actions in the CHANGELOG.Tests
791 tests green locally (API Platform 4.4.10, PHP 8.4). New kernel and unit tests for the context per caller, the fail-closed cases, untouched class contexts, headers and ETags; the regression test for the Hydra ETag fails on 0.10.0.
🤖 Generated with Claude Code
Closes #21