Symfony: Routing 'secure' and 'login' actions to another application

1.2k Views Asked by At

Suppose we have 3 apps - appMain, app1 and app2.

Applications 1 and 2 are protected, they have is_secure: true and everything works fine with sfDoctrineGuard plugin.

A behavior I want to achieve is when a user is not authenticated, current application to forward him to another one, say appMain with defined module and action.

Is that possible? Or can someone tell me where to dig about security mechanisms in symfony?

3

There are 3 best solutions below

0
On BEST ANSWER

Ok, now I got this working. First, application forwards to secure module/action and in that action it redirects to an url of main application, that handles authentication and redirects back again.

Thanks, guys.

2
On

Assuming you have the standard apps/frontend then in apps/frontend/config there will be a file settings.yml

in here in the default section do as follows

default:
  .actions:
    error_404_module:       content
    error_404_action:       404

    login_module:           security
    login_action:           login

this will then redirect to security/login (or whatever you call the module and the templates)

I usually set the top level apps/frontend/config/security.yml to ..

default:
  is_secure: true

this secures the whole site, then in any publicly accessible modules, in this case security create a config.yml and set as follows

default:
  is_secure: false

you will then need to store the fact that authenticated is true when the user logs in as follows

$this->getUser()->setAuthenticated(true);

[edit] should point out i am not using sfDoctrineGuard

2
On

Make absolute url and redirect there ("Keep It Simple, Stupid").