Skip to content

feat(hydra): filter the Hydra documentation and the entrypoint per caller (0.10.0) - #27

Merged
schmunk42 merged 8 commits into
masterfrom
feature/utils-hydra-filter
Dec 1, 2026
Merged

schmunk42 merged 8 commits into
masterfrom
feature/utils-hydra-filter

Conversation

@schmunk42

Copy link
Copy Markdown
Member

Summary

The per-caller filter of 0.9.0 now covers all three discovery documents: the OpenAPI document, the Hydra documentation /api/docs.jsonld and the entrypoint /api (JSON-LD, HAL, JSON:API). Same rule everywhere: the operation's security expression plus the firewall's access_control.

  • Refactors first: the per-operation access decision moves into OperationAccessDecider, the positional Hydra entry mapping into DocumentedOperationMap; no behaviour change for the OpenAPI document.
  • Configuration: new discovery.filter_operations_by_security and discovery.show_object_dependent_operations; the openapi.* keys stay as deprecated aliases until 0.12.0. Contradictory values, an environment placeholder in the filter switch and values that cannot be proven equal fail the container build.
  • Hydra documentation: denied operations disappear, a class that lost all its operations is removed with its entrypoint property, error classes and classes without operations stay, unmatched entries are denied, a document without the hydra: prefix is answered with a document without classes. References to removed classes are dropped from range, hydra:expects and subClassOf; hydra:returns keeps its name on purpose.
  • Entrypoint: a format shows a link only if the caller may execute the operation behind the URL that format emits; no fallback to another allowed operation.
  • Headers: the filtered Hydra documentation and entrypoint carry Cache-Control: private and Vary: Authorization.

Consumer action

Set api_platform.serializer.hydra_prefix: true or switch the filter off, otherwise /api/docs.jsonld loses its classes. Move from openapi.* to discovery.* before 0.12.0. Details in CHANGELOG.md (0.10.0) and README.md.

Tests

724 tests green locally (PHP 8.4, API Platform 4.4.10), up from 506. The new kernel test classes run in separate processes because the suite is close to PHP's 128 MB memory limit.

The JSON-LD contexts (/api/contexts/*) are not filtered yet.

Part of #21

🤖 Generated with Claude Code

schmunk42 and others added 8 commits November 30, 2026 23:16
…rationAccessDecider [*]

GrantSetResolver delegates the security and access_control decision to a
decider that judges a single HttpOperation, whether or not it has an
OpenAPI entry. The grant set and the OpenAPI filter are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…OperationMap [*]

The mapping from a documented Hydra entry to its operation moves out of
HydraDocumentationSubscriber into a service of its own, so a later filter
can share it. The enriched documentation is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…es [*]

discovery.filter_operations_by_security and
discovery.show_object_dependent_operations switch every discovery
document. The openapi.* keys stay as deprecated aliases until 0.12.0; a
contradiction between old and new key, an env placeholder in the filter
switch and values that cannot be proven equal fail the container build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
/api/docs.jsonld shows a caller only the operations the caller may
execute, by security expression and access_control. A class that lost all
its operations is removed with its entrypoint property; error classes and
classes without operations stay. Unmatched entries are denied, and a
document of unknown shape (no hydra: prefix) becomes an empty document.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
/api and /api/index.<format> in JSON-LD, HAL and JSON:API show a link
only when the caller may execute the operation that format links to. The
decision is made on the emitted URL, so no format falls back to another
allowed operation; an unmatched URL is dropped.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rivate [*]

/api/docs.jsonld and the entrypoint in every format now depend on the
caller, so they carry Cache-Control: private and Vary: Authorization like
the OpenAPI document, also under a public cache configuration. With the
filter off API Platform's headers stay.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ntation [*]

A remaining class no longer names a removed class in range, hydra:expects
or subClassOf; the property or operation itself stays documented.
hydra:returns keeps its name on purpose: api-doc-parser discards an
operation without it, and the caller sees that type in the response.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…point, release 0.10.0 [*]

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@schmunk42 schmunk42 self-assigned this Dec 1, 2026
@schmunk42
schmunk42 merged commit 959ecad into master Dec 1, 2026
2 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