I need to have a single login page for multiple Symfony apps. The login page is a Symfony app as well. All of these apps belong to the same Project (they will share some common data model elemtents).
The idea is that according to which app the user belongs to, the user will be forwarded after login to that app's homepage. The user won't be able to access pages in other apps.
The login app will have a db with the users, besides that, each app will access its own database.
How do I implement this??
Nate Flink answers:
You want to use the sfGuard plugin. This is the defacto login module for the symfony framework, that everyone uses, and is stable and fairly well developed.
It will handle the whole user management piece for you. You can use the same login facility for different apps, and you can override / customize the functionality as well.
1) It should be possible to write an import script to move your existing users over to the sfGuardUser and sfGuardUserProfile tables, while preserving the existing keys.
2) sfGuard plugin comes in both a propel and a doctrine version. Here is the doctrine version: http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin
Ok that looks promising.
I have one concern thou, I already have a table with the users, and their ids are foreign keys in other tables. The application has been running for a while and the db is big, from what I read about sfGuardPlugin it seems its expected to be used from the very start. Do you know if its possible to adapt sfGuardPlugin to an existing app like mine?
also, my app uses Doctrine not Propel :S
I see.. what kind of script would I need to transfer the users while keeping the keys to the other tables? Just changed in the YAML file or some MySQL script?
Bill Hunt answers:
As mentioned above, sfGuard is a great way to do this - there's also sfDoctrineGuardPlugin to handle your Doctrine requirement. You can use a custom method to validate your users using the old tables you've got, and a little fancy routing and re-routing can handle taking the user to a different page after login.
So u say I could keep my current User table and somehow link it to the new ones SfGuard creates? any hints on how to achieve that?
Bill Hunt comments:
RTFM. ;) It's not that hard, really.
Ok I installed sfGuardDoctrine, it seems very powerful I wonder why it doesn't just come as part as Symfony.
Anyway. Going back to the original question of this post.. any hints on how the single login for different apps can be achieved using this plugin?
got it! the plugin makes it very easy.