Question

This seem to be a simple question but I could not find any answer so far. What I want to do is blocking logged-in users to specific paths (login, register,...). Logically those paths must be allowed for guests (non-login users).

My question is:

  1. Is it possible to be configured only inside security.yml? If yes, how?

  2. If no, are there more convenient ways (e.g: I can config all such permissions/paths in one place like what I am doing in security.yml) to achieve that result without using $securityContext->isGranted('ROLE_USER') in each path?

No correct solution

OTHER TIPS

If you are using symfony 2.4, then there is a way you can specify this in the security.yml file. The the docs Securing by expression.

Basically, in your access_control section, you can have a allow_if entry that allows you to have a custom conditional expression.

You can use an expression similar to this:

allow_if: "not is_authenticated()"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top