Skip to content

Specify a different user when checking isGranted #57639

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

Closed
pauljura opened this issue Jul 4, 2024 · 2 comments
Closed

Specify a different user when checking isGranted #57639

pauljura opened this issue Jul 4, 2024 · 2 comments

Comments

@pauljura
Copy link

pauljura commented Jul 4, 2024

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

@Seb33300
Copy link
Contributor

Seb33300 commented Jul 4, 2024

Are you trying to impersonate an user?
https://symfony.com/doc/current/security/impersonating_user.html

@wouterj
Copy link
Member

wouterj commented Jul 4, 2024

Hi! We've another issue about this topic already: #43372 So I'm going to close this one as duplicate.

@wouterj wouterj closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants