简体   繁体   English

允许某些用户查看Symfony中的特定URL

[英]Allow certain users to see specific URLs in Symfony

I am currently struggling with an access_control problem : 我目前正在努力解决access_control问题:

I need every user to access every page on /user. 我需要每个用户访问/ user上的每个页面。

But I need one user (ie a particular role ) to access only certain pages on /user (Let's say /user/profile and /user/register) 但是我需要一个用户(即特定角色 )才能访问/ user上的某些页面(比方说/ user / profile和/ user / register)

To clarify, I need a user that can access LESS pages than a regular user 为了明确起见,我需要一个比普通用户可以访问更少页面的用户

I have been looking into access control but cannot find a way to implement this behavior apart from specifying it into every /user controller of my application. 我一直在研究访问控制,但是除了将其指定到我的应用程序的每个/ user控制器之外,没有找到实现此行为的方法。

Did you try to put rules in your app/config.security.yml, like : 您是否尝试将规则放在app / config.security.yml中,例如:

security:
    access_control:
        - { path: ^/user/profile/$, role: YOUR_CUSTOM_ROLE }

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 symfony2 / php:仅将URL限制为特定用户 - symfony2/php: restrict urls to specific users only 只允许用户来自数据库的某些信息 - Allow users only certain information from database 只允许某些用户编辑ASPxGridView - Only Allow Certain Users to Edit ASPxGridView 是否有一个简单的代码允许某些用户访问查看命令按钮? - Is there a simple code to allow certain user(s) access to see command buttons? 仅允许具有特定角色的用户使用Spring Security登录 - Only Allow Login With Spring Security For Users With Certain Roles 如何存储敏感文件,仅允许访问某些用户 - How to store sensitive files and only allow access to certain users Symfony标记化URL无效 - Symfony Tokenized URLs not working 如何设置 git 存储库,不同的用户只能看到某些部分? - How to set up a git repository where different users can only see certain parts? Symfony:为某些类型的用户取消对后端模块的保护。 如何? - Symfony: un-secure a backend module for certain kinds of users. How? ASP.NET-可以创建一个DetailsView,仅具有特定角色的用户将某些字段视为可编辑的吗? - ASP.NET - Can you make a DetailsView where only users with specific roles see some fields as editable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM