【问题标题】:Can I use routes in access_control security configuration?我可以在 access_control 安全配置中使用路由吗?
【发布时间】:2023-04-04 00:12:02
【问题描述】:

我可以在 access_control 安全配置中使用路由吗? 没有任何关于在安全配置中使用路由的信息。 我不想在 routing.yml 和 security.yml 中支持两个类似的 URL 路径定义。我只想定义一个新路由并将其名称提供给安全 access_control 部分。 有可能吗?

【问题讨论】:

  • 你到底想用那条路线做什么?
  • 我只想将 URL 生成信息存储在路由配置中并在防火墙中使用。

标签: symfony


【解决方案1】:

没有办法做到这一点。

指定的path 直接作为RequestMatcher$path 参数传递。

访问映射条目在此处注册到访问映射中: 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

如果您查看RequestMatcher 的代码,您会发现它没有与任何路由系统耦合: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcher.php

【讨论】:

猜你喜欢
  • 2015-12-06
  • 2017-01-21
  • 2019-10-21
  • 2014-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-06
相关资源
最近更新 更多