Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[SecurityBundle] ExpressionCacheWarmer uses wrong attributes #40087

Closed
@wickedOne

Description

@wickedOne

Symfony version(s) affected: 5.2.2

Description
when using the role_names attribute in an expression of your access control configuration, warming the cache will fail with an Variable "role_names" is not valid around position... message because the cache warmer expects a roles attribute.

$this->expressionLanguage->parse($expression, ['token', 'user', 'object', 'subject', 'roles', 'request', 'trust_resolver']);

the documentation on this feature also is confusing as the given example uses role_names while the description uses the roles attribute: https://symfony.com/doc/current/security/expressions.html

How to reproduce
add the following in your acces_control config of the security config and run a bin/console cache:clear:

    access_control:
        - { path: '^/', allow_if: "'ROLE_ADMIN' in role_names"}

Possible Solution
change the roles attribute to role_names in the ExpressionCacheWarmer and correct the documentation accordingly.

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