EasyCorp / EasyCorp/EasyAdminBundle

Method setEntityPermission doesn't work properly

Open
#7,262 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
PHP
Stars
4.3k
Forks
1.1k
Avg merge
8d 2h
Merged PRs (30d)
11

Description

From the documentation:

You can also restrict which items users can see in the index and detail pages thanks to the setEntityPermission() method.

I want to restrict access to the index and detail pages to employees who share the same profile property as the current user:

public function configureCrud(Crud $crud): Crud
{
    return $crud
        ->setEntityPermission(
            new Expression("subject.profile === user.profile")
        )
    ;
}

And it doesn't work. Expression seems to work fine for edit, delete and detail actions instead.

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the security documentation section on setEntityPermission() and trace the configureCrud() entry point using the provided Expression example. Compare permission handling for index and detail pages with edit, delete, and detail actions. Done means an expression such as subject.profile === user.profile correctly restricts the index and detail pages, with coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
authorization, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.