Convergence IT
Convergence IT

Reputation: 73

Symfony 3 access_control regex expression

I'm in Symfony 3.4, I want to allow access to some URLs for no authenticated users. For that I used Regex expression like bellow, but it gaves error of syntax in security.yml . Expression: - { path: ^/link/[0-9]\{0,}/download/, role: IS_AUTHENTICATED_ANONYMOUSLY}. [0-9]{0,} : for numbers. Any help, thanks

Upvotes: 2

Views: 1165

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626794

I suggest matching 1 or more digits rather than 0 or more, and you should use roles, not role, to define the role:

path: ^/link/[0-9]+/download/,
roles: IS_AUTHENTICATED_ANONYMOUSLY

Note that \{0,} matches a literal {0,} string as you escaped the first open brace thus corrupting the limiting quantifier.

Upvotes: 3

Related Questions