我可以在 access_control 安全配置中使用路由吗? [英] Can I use routes in access_control security configuration?
问题描述
我可以在 access_control 安全配置中使用路由吗?在安全配置中没有关于使用路由的任何信息.我不想在routing.yml 和security.yml 中支持两个相似的URL 路径定义.我只想定义一个新路由并将其名称提供给 security access_control 部分.可能吗?
Can I use routes in access_control security configuration? There is no any information about using routes in security configuration. I don't want to support two similar definitions of URL paths in routing.yml and security.yml. I just want to define a new route and provide its name to the security access_control section. Is it possible?
推荐答案
没有办法做到这一点.
指定的path
直接作为RequestMatcher
的$path
参数传递.
The specified path
is directly passed as the RequestMatcher
's $path
argument.
访问映射条目在此处注册到访问映射中:https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L165-187
The access map entries are registed into the access map here: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L165-187
使用使用此方法创建的请求匹配器:https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L539-561
Using the request matchers created using this method: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L539-561
如果您查看 RequestMatcher
的代码,您会发现它没有与任何路由系统耦合:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcher.php
And if you take a look at the RequestMatcher
's code, you see it's not coupled to any routing system:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcher.php
这篇关于我可以在 access_control 安全配置中使用路由吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!