Code Monkey home page Code Monkey logo

lswsecurecontrollerbundle's People

Contributors

fludimir avatar gregoirehebert avatar jcchavezs avatar mevdschee avatar nyholm avatar tobyryuk avatar

Stargazers

 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  avatar  avatar  avatar  avatar

lswsecurecontrollerbundle's Issues

Allow an object

I would like to pass an object in the annotation. Like

    /**
     * @Secure(roles="ROLE_TEST")
     * @Secure(roles="EDIT", "company")
     * @Route("/company/{id}/edit", name="edit_company")
     */
    public function helloAction($company)
    {
        return array('name' => $company->getName());
    }

This will take the parameter $company and run $this->authorizationChecker->isGranted($role, $company)

Im happy to make a PR to achieve this but I would like to hear your thoughts first.

Using multiple roles

When you specifiy several roles une the @secure annotation an AND is done beetwen the roles.
It is more logical to do an OR as done int the JMS bundle because you can filter it in the controller function.

To do it you must change in the Lsw\SecureControllerBundle\Security\ControllerListener onKernelController function

            if (!$this->securityContext->isGranted($role)) {
                throw new AccessDeniedException(
                    'Current user is not granted required role "'.$role.'".'
                );
            }
        }

by

            if ($this->securityContext->isGranted($role)) return;
        }
        throw new AccessDeniedException('Current user is not granted');

Check if controller is a "Controller object"

The ControllerListener does not check if the $controller is a Symfony Controller object.
By design the controller could be any callable.
So before line: list($object, $method) = $controller
The $controller should be checked if it is an array.
E.g.:

if (!is_array($controller = $event->getController())) {
    return;
}

Avoid warnings in Symfony 2.8 by using quotes for declaring dependencies.

In Lsw/SecureControllerBundle/Resources/config/services.yml:

services:
    secure_controller.controller_listener:
        class: %secure_controller.controller_listener.class%
        arguments: [@annotation_reader,@security.context]

Both @annotation_reader and @security.context must be quoted for avoiding warnings in Symfony 2.8.

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.