Search by

phil / content-access-bundle

phil

Show each person only the content they may see in Symfony: voters, Twig checks, per-request cached grants, and a 404 with the right cache headers.

Package info

github.com/parler-haut-interagir-librement/content-access-bundle

Homepage

Type:symfony-bundle

pkg:composer/phil/content-access-bundle

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0-alpha 2026-11-29 22:00 UTC

This package is auto-updated.

Last update: 2026-11-30 02:53:11 UTC


README

Decide in a Symfony application who reads each content — from the person signed in, their grants and the application's facts — and never send the reserved part to whoever may not read it.

phil/content-access-bundle brings phil/content-access to a Symfony application. The library decides, for a viewer at an instant, whether a content is read in full, as a preview before its cut, as a locked entry or not at all; the bundle gives it the viewer of the request — the user of Symfony Security, the roles their token reaches, a verified email domain and the client address behind the trusted proxies — and the grants of the sources the application tags, read once per person and request and forgotten between two requests of a worker.

A content of the application implements ProtectedContent, and the providers of facts the application tags tell a rule what the application knows of that content and that viewer, such as a lesson completed. A content everyone reads asks for neither: the session stays unread, and the response cacheable. The application's own condition types join the generic comparisons and the four types of access in one registry.

A voter answers phil_content_access.read — the whole content — and phil_content_access.view — the content appears at all. Twig functions give the decision, the blocks of a UJO (Universal JSON Output) document the decision lets through, and the schema.org properties of the policy, the same for every viewer. DecisionResponses answers a hidden content with the same 404 as a missing one and keeps a personal decision out of every cache. A command checks stored policies against the registry and prints their fingerprint.

When phil/commerce-subscription-bundle is enabled, the features of a person's subscriptions are grants.

Status

Part State
The viewer from Symfony Security, the grants cached per request, the facts and condition types tagged Implemented and tested
ContentAccess, the voter, the Twig functions, the 404 and the cache headers Implemented and tested
The command phil:content-access:lint-policy Implemented and tested
The features of phil/commerce-subscription-bundle as grants Implemented and tested
The administration of policies in pages, the private RSS feed by revocable token, the email at the end of an access Not written

Documentation

Document What it covers
Installation Requirements, the bundle, Security, and a first protected page.
Configuration Every option, with an example.
Usage The viewer, ContentAccess, the voter, the Twig functions, the HTTP responses and the command.
Extension points Sources of grants, facts, condition types, the subscriptions, what is stable.
Testing The tests and the application they run in.
Reference Every public type and service, with its role.

Quick start

composer require phil/content-access-bundle
use Phil\ContentAccessBundle\Infrastructure\Security\ContentAccessVoter;

#[IsGranted(ContentAccessVoter::VIEW, subject: 'episode', statusCode: 404)]
public function show(Episode $episode): Response
{
    return $this->render('episode.html.twig', ['episode' => $episode]);
}
{% set decision = content_access(episode) %}
{% for block in content_visible_blocks(decision, episode.document.blocks) %}
    {{ include('blocks/' ~ block.type ~ '.html.twig') }}
{% endfor %}

Requirements

PHP 8.5 or later, Symfony 8.2 with FrameworkBundle, and phil/content-access. SecurityBundle gives the viewer signed in, TwigBundle the functions, the Console the command; each is optional.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.