Symfony - how to deal with credentials that contain spaces in security.yml?

351 Views Asked by At

Seems like a simple issue, but I can't find the proper reference.

I have a system that has some permissions that have spaces in them:

contract admin

I need to secure an action, so in security.yml i have:

action:
    is_secure:    on
    credentials:  contract admin

However, it doesn't work: the user with this permission will still be restricted.

I've tried putting the credentials in single and double quotes and square brackets, but it always fails. If i change the credential to one with no spaces, it works fine.

I might be able to rename the credential, but ultimately i'd like to know the solution to this issue.

3

There are 3 best solutions below

0
On
action:
  credentials: [ "contract admin" ]

Try this. The credentials should be on brackets. For more information:

action1:
  credentials: [ this, andThis ] # AND

action2:
  credentials: [[ this, orThis ]] # OR
1
On
action:
    is_secure:    on
    credentials:  "contract admin"

should work

0
On

I think you need to use it like this:

//security.yml:

your_module:
  is_secure: true
  credentials: [your_credential_name]