Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Acl Doctrine Filter Bundle Laravel Package

a5sys/acl-doctrine-filter-bundle

View on GitHub
Deep Wiki
Context7

Deprecated in favor of https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/filters.html

AclDoctrineFilterBundle

This bundles allow to filter doctrine entities automatically

Installation

Composer

composer require "a5sys/acl-doctrine-filter-bundle"

Activate the bundle

In your AppKernel, add the bundle:

new A5sys\AclDoctrineFilterBundle\AclDoctrineFilterBundle(),

Configuration

Add the doctrine filter configuration to your config.yml

doctrine:
    orm:
        filters:
            acl:
                class: 'A5sys\AclDoctrineFilterBundle\Filter\AclFilter'
                enabled: true

You can also disable the ACL for some roles:

acl_doctrine_filter:
	    no_acl_roles:
	        - "ROLE_ADMIN" #mandatory list of user roles that does not have acl

Usage

Guess you have 3 entities:

  • User
  • UserProject (link between user and project, it is our acl)
  • Project

In your code, if you do:

	$projectRepository->findAll();

You will get all projects without any ACL

Modify the Project.php entity, add the AclAnnotation:

namespace AppBundle\Entity;

** use A5sys\AclDoctrineFilterBundle\Annotation\AclAnnotation;** use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="project")
 * @ORM\Entity
 * @AclAnnotation(aclSql="##TABLEALIAS##.id in (select distinct project.id from project inner join user_project ON user_project.project_id = project.id where user_project.user_id = ##USERID##)")
 */
class Project
{
....

and automatically, the sql of the annotation will be appended to all SQL queries and no forbidden entities will ever be retrieved.

You do the same for all entities you want to protect with ACL.

Reserved keyword

##TABLEALIAS##

This keyword will be automatically replaced par the table alias generated by the DQL

##USERID##

This keyword will be automatically replaced par the id of the logged user

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui