Skip to content

Instantly share code, notes, and snippets.

View leotiger's full-sized avatar

Uli Hake leotiger

View GitHub Profile
@leotiger
leotiger / allowed_roles_for_route.md
Last active March 2, 2024 01:29
Symfony3: Check if a route is accessible for a ROLE or a list of ROLES

I've implemented this in a current project as a service. The solution is straightforward but depends on security annotations. You may adapt the solution to fit your needs... It should be easy to use custom annotations or to combine this with configuration options running in from config.yml or a database.

This is related with Symfony Issue #6538

namespace Acme\Security\Roles;

use Symfony\Component\HttpFoundation\Request;