GithubHelp home page GithubHelp logo

symfony / acl-bundle Goto Github PK

View Code? Open in Web Editor NEW
110.0 17.0 38.0 87 KB

Integrates the ACL Security component into Symfony applications.

Home Page: https://symfony.com/acl-bundle

License: MIT License

PHP 100.00%
php symfony bundle symfony-bundle acl

acl-bundle's Introduction

Access Control List Bundle

The ACL bundle makes it possible to grant authorization based on resources.

Read the bundle documentation.

Tests

You can run the unit tests with the following command:

$ cd path/to/acl-bundle/
$ composer.phar install --dev
$ ./vendor/bin/simple-phpunit

acl-bundle's People

Contributors

acrobat avatar andreybolonin avatar anyt avatar cedricziel avatar chalasr avatar derrabus avatar fabpot avatar iamvar avatar javiereguiluz avatar linaori avatar mbabker avatar pamuche avatar tobion avatar wouterj avatar xabbuh avatar xwb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acl-bundle's Issues

Followed the examples, but got: Service "security.acl.provider" not found

I followed the example: https://github.com/symfony/acl-bundle/blob/master/src/Resources/doc/index.rst
`
class BlogController extends Controller
{
// ...

public function addCommentAction(Post $post)
{
    $comment = new Comment();

    // ... setup $form, and submit data

    if ($form->isSubmitted() && $form->isValid()) {
        $entityManager = $this->getDoctrine()->getManager();
        $entityManager->persist($comment);
        $entityManager->flush();

        // creating the ACL
        $aclProvider = $this->get('security.acl.provider');
        $objectIdentity = ObjectIdentity::fromDomainObject($comment);
        $acl = $aclProvider->createAcl($objectIdentity);

        // retrieving the security identity of the currently logged-in user
        $tokenStorage = $this->get('security.token_storage');
        $user = $tokenStorage->getToken()->getUser();
        $securityIdentity = UserSecurityIdentity::fromAccount($user);

        // grant owner access
        $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
        $aclProvider->updateAcl($acl);
    }
}

}
`

But after submitting the form, I got:

Service "security.acl.provider" not found: even though it exists in the app's container, the container inside "App\Controller\Web\BlogController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "session" and "twig" services. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "BlogController::getSubscribedServices()".

Tests are broken since symfony/dependency-injection:4.4

I've tried to update dependencies of acl-bundle to sf5 but it was unsuccessful. Since tests are broken from symfony/dependency-injection:4.4.0. Commit which affected tests -
https://github.com/symfony/dependency-injection/commit/ddb02286fb427dc6aba02cabc150f21b40aeb349 (@nicolas-grekas )

Example of error message from tests

  1. Symfony\Bundle\AclBundle\Tests\DependencyInjection\PhpCompleteConfigurationTest::testAcl
    Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "security.acl.security_identity_retrieval_strategy" has a dependency on a non-existent service "security.role_hierarchy".

acl-bundle/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:86
acl-bundle/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:82
acl-bundle/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
acl-bundle/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:91
acl-bundle/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
acl-bundle/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:82
acl-bundle/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
acl-bundle/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:46
acl-bundle/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:40
acl-bundle/vendor/symfony/dependency-injection/Compiler/Compiler.php:94
acl-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php:762
acl-bundle/tests/DependencyInjection/CompleteConfigurationTest.php:56
acl-bundle/tests/DependencyInjection/CompleteConfigurationTest.php:27

Dependence on Dependency Injection/Container

I want to use this bundle in my exiting Laravel 5 application, but it seems to be dependent on the Symfony dependency container whereas all of my dependencies are managed inside Laravel's IOC containers. Am I required to use the Symfony's dependency container for getting such this

$aclProvider = $this->get('security.acl.provider');

Or I can independently register the Security ACL dependency in my Laravel container and get it from there? I don't want to keep track of two different object containers in my application.

 "require": {
        "php": "^5.5.9|>=7.0.8",
        "ext-xml": "*",
        "symfony/dependency-injection": "~3.4|~4.0",
        "symfony/http-kernel": "~3.4|~4.0",
        "symfony/security-acl": "~2.7|~3.0",
        "symfony/security-bundle": "~3.4|~4.0"
    },

Can I register the security services inside my Laravel Container? If yes what are the services that are required for the ACL bundle in order to make it work?

Documentation

Is there "symfony/acl-bundle" documentation for Symfony4?

GitHub page points to Symfony documentation and Symfony back to GitHub. It looks official documentation is somehow missing.

Symfony 4.3 User Deprecated

  • A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.

  • The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "acl" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.

Symfony 7 support

The composer.json allows only Symfony 6 at the moment, so the bundle cannot be install on Symfony 7 code.
Would it be possible to allow Symfony 7?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.