PHP verify that user has access to content

不羁岁月 提交于 2019-12-13 21:05:42

问题


I am building an ACL plugin to my framework / application.

The previous ACL applications i have worked with has a controller / action verification meaning that it checks if the user has access to both the controller and the view.

Now in many applications a user can have access to both the controller and the view but still not have acess to the content.

Forexample:

user1 has access to the controller: games and the view: play but not have access to the id: 1

My first idea was to check the $_GET variable but this is not sufficient since it is impossible to know what the variable that the content is looking for.

So my question is how would you verify that the user has access to the content of the view?


回答1:


Well, you do know the id of the content in your Controller and you do know the user trying to access it. Just add contentId to your ACL check routine? You just have to add more ACL data, current implementation with just controller and method isn't enough in these cases.

e.g. $acl->userIsAllowedTo('view', 1, 'gamescontroller') or so.



来源:https://stackoverflow.com/questions/28319852/php-verify-that-user-has-access-to-content

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!