Skip to content

Specify a different user when checking isGranted #57639

Closed as not planned
Closed as not planned
@pauljura

Description

@pauljura

Description

I like the idea of voters, but the problem is that they only work for the currently logged in user. I would like to perform access checks on behalf of other users.

Take the standard blog website as an example. Users have access to posts. But suppose I want to share a post with other users. I want to know whether Alice can view the post, to see if I can share it with her.

So instead of writing

if ($this->isGranted('view', $post)) { ... }

I want to write

if ($this->isGranted('view', $post, $user)) { ... }

Another use case would be for command line processes. For example, Bob requests to run a report that takes a long time. I have a command that runs in the background, and I want it to verify that Bob has access to the report he is requesting. I can't do that right now with voters.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions