Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Using isGranted() without a Session #43372

Copy link
Copy link
Closed
@natewiebe13

Description

@natewiebe13
Issue body actions

Description
isGranted() assumes that it's checking against the currently logged in user. It would be great to be able to use something similar to check against another user or during times when there isn't a session (cronjobs/commands, message queue, etc.).

I would see this as a userIsGranted() function to make a distinction. There's cases we'd have to consider, such as if IS_AUTHENTICATED_* is used in conjunction with this method, as those are based on sessions. Return false, or throw a logic exception, etc.

Having this functionality would allow for removing the dependency on sessions entirely for services reducing the number of issues that come up during a project because some underlying function was session dependent.

I'm assuming we'd also want to create a new Token class to represent checking against a non-logged in user.

Example
Checking to see if you could assign another user to review an article:

$security->userIsGranted($reviewer, ArticleVoter::REVIEW, $article);

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.