[英]Symfony3 regex access_control in security.yml
I can not find the right regex to define a security rule for the following pattern:我找不到正确的正则表达式来为以下模式定义安全规则:
http://example.com/ manager/?conf=xxxxx http://example.com/经理/?的conf = XXXXX
It is to be able to access different directory according to the connected user.它是为了能够根据连接的用户访问不同的目录。
for example:例如:
/manager/conf=superadmin, role: ROLE_SUPER_ADMIN
/manager/conf=admin, role: ROLE_ADMIN
/manager/conf=user, role: ROLE_USER
Thank you in advance for your help.预先感谢您的帮助。
As far as I know Symfony doesn't check query string.据我所知 Symfony 不检查查询字符串。 In your case the best option would be to define a route path like this:
/manager/conf/{role}
and then configure access_control:在您的情况下,最好的选择是定义这样的路由路径:
/manager/conf/{role}
然后配置 access_control:
/manager/conf/superadmin, role: ROLE_SUPER_ADMIN
/manager/conf/admin, role: ROLE_ADMIN
/manager/conf/user, role: ROLE_USER
Or depending how your configuration manager works, you could load a configuration using $role
parameter that will be passed to your controller.或者根据您的配置管理器的工作方式,您可以使用将传递给您的控制器的
$role
参数加载配置。
Another option is to use Voters ( https://symfony.com/doc/current/security/voters.html ) to verify if the user should be granted access to your resource.另一种选择是使用 Voters ( https://symfony.com/doc/current/security/voters.html ) 来验证是否应该授予用户访问您的资源的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.