Skip to content

isGranted() or is_granted() does not accept an array of ROLEs #37132

Closed
@tbs-trappy

Description

@tbs-trappy

Symfony version(s) affected: all

Description
Passing an array into is_granted always returns false, while checking for the same as a individual role does not return false. according to the documentation, is_granted is supposed to support arrays as well as strings.

How to reproduce
{{ dump(is_granted(["ROLE_ADMIN"]) }}
{{ dump(is_granted("ROLE_ADMIN")) }}

Possible Solution
security-core/Authorization/Voter/RoleVoter.php
line 39++ needs to be rewritten to accept an array of $attribute in order to satisfy the specification that is_granted can accept both string and string[] (ref: https://symfony.com/doc/current/reference/twig_reference.html#is-granted)

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