Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there some options to check the permission of an other user than the logged one #34

Open
GreGosPhaTos opened this issue Mar 15, 2016 · 4 comments

Comments

@GreGosPhaTos
Copy link

Is not an issue it's more a question :
But is there a way to check the permission for an other user than the user connected in my application through the AclManager ?

Let's say I want to check if a user has the EDIT permission on the field A on a class B.

I have tried to extends the AclManager to create a isUserGranted method and tried to use the ACL's isGranted method instead of the securityContext one, but it seems doesn't work.

The other option would be to inject an other SecurityContext instance into the manager ?
Any advises will be accepted thanks

@GreGosPhaTos
Copy link
Author

Ok actually I found a way it's a bite dirty but it's works fine ;) :

class AclCustomManager extends AclManager
{    
    public function isUserGranted($attributes, $user, $object, $field = null)
    {
        $token = new UsernamePasswordToken($user, null, 'your_firewall_name', $user->getRoles());
        $oldToken = $this->getSecurityContext()->getToken();
        $this->getSecurityContext()->setToken($token);
        $isGranted = $this->isGranted($attributes, $object, $field);
        $this->getSecurityContext()->setToken($oldToken);
        return $isGranted;
    }
}

@bytehead
Copy link
Member

PR #29 solves your exact issue probably, doesn't it?

@GreGosPhaTos
Copy link
Author

@bytehead Cool didn't see that, well it seems to solve my problem, but does it works with the class field permission for example ?

Thanks

@bytehead
Copy link
Member

@GreGosPhaTos I don't know. But @badaz should probably know it ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants