I have been trying to get setup with symfony2 for a while now and it has been going well for quite a while, but I've hit a bit of a snag. I can't figure out how to get my security setup. At our institution, we have a installation of cas (single sign on) and a static class that deals with all of the authentication stuff. It is called gatekeeper. Gatekeeper does all of the role checking and username login stuff. I want to be able to use the authorization stuff of symfony2, but none of the authentication stuff. Is this possible? I have read the documentation but it seems like those things are too tightly bound to be separated. Does anyone have any insights on this topic?
If you are using your Gatekeeper class for authentication before the request hits the firewall you can create a "pre-authenticated" (i.e. authentication happens before the firewall) listener by extending AbstractPreAuthenticatedListener and implementing getPreAuthenticatedData():
class GatekeeperListener extends AbstractPreAuthenticatedListener
{
protected function getPreAuthenticatedData(Request $request)
{
return array(
Gatekeeper::getCurrentUsername(), // username
'', // credentials
);
}
}
You will need to create a security factory in order to introduce a new authentication listener to the system. This process is described in this cookbook article:
How to create a custom Authentication Provider: The Factory
Your security.yml should look something like this:
security:
factories:
- "%kernel.root_dir%/../src/Acme/DemoBundle/Resources/config/security_factories.yml"
firewalls:
main:
pattern: .
gatekeeper: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With