Skip to content

[Security] Make IsGranted Attribute non final to allow usage of custom attributes #60896

Open
@crtl

Description

@crtl

Description

Currently Symfony\Component\Security\Http\Attribute\IsGranted is declared final.

It would be helpful to make it non final so developers can use custom attributes to reuse roles that are used often. For example IsAdmin etc..

Example

namespace Symfony\Component\Security\Http\Attribute;

class IsGranted {
  // ...
}
namespace App\Security\Attribute;

class IsAdmin extends IsGranted {

  public function __construct() {
    parent::__construct("ROLE_ADMIN");
  }
}
namespace App\Controller;


class AdminController {
  #[IsAdmin]
  public function adminAction() {}
}

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