简体   繁体   English

更改不同角色的访问控制

[英]change access control for diffrent roles

A role Called ROLE_EDUCATOR cant seem to get files from a folder called uploads. 名为ROLE_EDUCATOR的角色似乎无法从名为uploads的文件夹中获取文件。

i tried to change the symfony security file where you can change level of access. 我试图更改symfony安全文件,您可以在其中更改访问级别。

This is the role role hierarchy set in the file 这是在文件中设置的角色角色层次结构

role_hierarchy:
        ROLE_LOCATION_MANAGER: [ROLE_EDUCATOR]
        ROLE_ADMIN: [ROLE_LOCATION_MANAGER]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN]

what needs to change is the uploads/avatars path where avatars/foto's are pulled from 需要更改的是从中提取化身/照片的上传/化身路径

access_control:
        - { path: ^/uploads/, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/uploads/avatars, role: IS_AUTHENTICATED_ANONYMOUSLY }

the result i got from loging in as a user with roles higher than ROLE_EDUCATOR is that i could see the images load but as i log in as educator role the image becomes the a image like the ones you see where the src is not linked good 我以具有高于ROLE_EDUCATOR角色的用户身份登录时得到的结果是,我可以看到加载的图像,但是当我以教育者角色登录时,该图像变成了一个图像,就像您看到的src未链接好一样

try this: 尝试这个:

access_control:
        - { path: ^/uploads/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/uploads/avatars, roles: IS_AUTHENTICATED_ANONYMOUSLY }

so just change the role to roles 所以就换roles

https://symfony.com/doc/current/security/access_control.html https://symfony.com/doc/current/security/access_control.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM