Questions tagged [symfony2-voter]

9 questions
4
votes
1 answer

Symfony2: Call Voter from another Voter

I am using Voters to restrict access to entities in a REST API. Step 1 Consider this voter that restricts users access to blog posts: class BlogPostVoter extends Voter { public function __construct(AccessDecisionManagerInterface…
MattW
  • 12,902
  • 5
  • 38
  • 65
1
vote
1 answer

Is it possible to set a new entity directly from twig?

Sometime i need to check if an user can comment from a voter, obviously at this point of the code the comment does not yet exist, but still i need to check if the user is allowed to comment or not. From the controller i would usually do…
1
vote
1 answer

Symfony Voter supports method receiving ROLE and Request instead attribute and entity

The Voter seems to work on my whole app... except on this controller: $entity = $em->getReference('AppBundle:Offer',$id); $this->denyAccessUnlessGranted('overview', $entity); Where this Voter method is receiving wrong arguments…
Arco Voltaico
  • 860
  • 13
  • 29
0
votes
1 answer

Symfony voter via subresource is not being called

Here is the context : I use Symfony 3.4 with api-platform. I have two class : Supplier Product I want to list all the supplier's product In the Supplier Entity I have implemented access_control on regular CRUD method that works fine with the…
brn
  • 275
  • 1
  • 6
  • 17
0
votes
1 answer

Protecting controller actions and routes in Symfony

Official documentation on Symfony pages suggest using ROLE_ADMIN (example) attribute in the ACL call $this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page!'); my question is if it is possible to use ACL call without the…
SuperManSL
  • 1,306
  • 2
  • 12
  • 17
0
votes
1 answer

Symfony Voter constant usages

I defined a voter, especially voteOnAttribute method like following : public function voteOnAttribute($attributes, $subject, TokenInterface $token) { $user = $token->getUser(); if (!$user instanceof User) { return…
nbonniot
  • 1,034
  • 16
  • 33
0
votes
1 answer

Symfony UserVoter gets current logged in User in place of User in the url

On an show user action, i want to check if the logged user has the right to see this user. So i created a UserVoter. But when I try to pass the user defined in the url to the Voter using annotation, I get the logged User using both $subject and…
0
votes
0 answers

ACL Or voters for managing access controls in Symfony 3

I am building a project with symfony 3 and trying to decide between Voters and ACL. Soi have many Roles like (SUPERADMIN, ADMIN, Office, bureau, manager,user...) and my project should give the superadmin the possibility to add any other role via the…
Chaymae
  • 427
  • 4
  • 7
  • 16
0
votes
1 answer

Calling voters in twig without second object

I'm developing a new symfony project and I implemented and custom voter. In a controller I can call the voters through $this->isGranted('view',$team), but for this, I need a team-object. When I want to display a team, it is no problem. But now I…
user3296316
  • 127
  • 2
  • 3
  • 16