silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

Is possible mount() by roles? #921

Closed mmuruev closed 10 years ago

mmuruev commented 10 years ago

I want make mount my silex modules by security role. Issue is that security context available only on controller call, but mount should call much earlier. Is this possible? I want have something like if($app['security']->isGranted('ROLE_ADMIN')){ $app->mount($class::ROUTE, new $class()); // Only admin available module }

davedevelopment commented 10 years ago

@mmuruev not that I'm aware of, you'll want to setup access rules for that

mmuruev commented 10 years ago

Yes, I know about access rules. This is not the same. In that case module even doesn't bind to url just as not loaded. Also access rules are weird thing. I can do only allow access but not restrict for url, also if you have few quite the same path it surprise even more. Any way I'm looking exactly for mount by roles.

fabpot commented 10 years ago

That's not possible as the security runs after the routing.