The RoleVoter documentation says:
RoleVoter votes if any attribute starts with a given prefix.
Default prefix RoleVoter will check ROLE_ , passed as the default parameter value to constuctor. They are necessary because the voter must check the current registered user.
Make sure your own voters implement VoterInterface , and also check the voter implementation of YourVoter::supportsClass . The FQN of the element from which you want to know the user has access to it, should be checked there. Then the following configuration should be sufficient:
app.security.download_voter: class: AppBundle\Security\Voter\DownloadVoter public: false tags: - { name: security.voter }
So:
1) You should not disconnect this voter, because all other voters rely on the RoleHierarchy , which this voter creates for the current user when voting takes place.
2) For a better understanding of Voter you can let the DIC enter logger into Voter and add additional information to the profiler. Thus, your own voters are no longer a black box.
source share