Skip to content

Navigation Menu

Sign in
Appearance settings

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

[Security] Symfony 6.x IsGranted attribute ignored at the controller class level #54542

Copy link
Copy link
Closed
@aless673

Description

@aless673
Issue body actions

Symfony version(s) affected

6.x

Description

The attribute IsGranted is ignored / not working when it is defined at the controller class level and when the controller service is lazy

Symfony doc about the feature at controller class level : https://symfony.com/doc/current/security.html#security-securing-controller-attributes

NB: at controller action level it works, this only happen when configured at the class level

How to reproduce

In this example, the attribute IsGranted doesn't deny the access to any user

use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted('ROLE_ADMIN')]
class AdminController extends AbstractController
{
    public function adminDashboard(): Response
    {
        ...
    }
}
    App\Controller\:
        resource: '../src/Controller/'
        lazy: true

Possible Solution

No response

Additional Context

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

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