Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony dynamic firewall

On a large webapplication, I want our customers to be able to enable/configure their own sigle sign-on (SAML) identity provider. Each customer has it's own specific subdomain allowing our application to determine which firewall should be active. However, I don't want to manually configure each new firewall and clear the cache before changes are taken into effect. Now I read about dependency injection, extensions, compilers and all that, but I just can't seem to find a way to load dynamic firewall settings from the database and apply them. Any idea how I would do this?

FYI, I am using the SamlSPBundle for SSO.

Thanks!

like image 720
symfoon Avatar asked Oct 13 '14 17:10

symfoon


1 Answers

I may have figured this out just moments after setting a bounty! ;)

Symfony2 security allows specification of a request_matcher on a per-firewall basis:

http://php-and-symfony.matthiasnoback.nl/2012/07/symfony2-security-using-advanced-request-matchers-to-activate-firewalls/

Custom RequestMatchers must implement a single method that returns true or false based on the Request object. I think this could be used to activate a firewall dynamically. As long as you have a finite number of firewalls (I do), then a custom RequestMatcher could solve your problem.

like image 194
astletron Avatar answered Oct 07 '22 18:10

astletron