为我的 PHP 应用程序实现 ACL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4415663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:59:59  来源:igfitidea点击:

Implementing ACL for my PHP application

phpaclaccess-control

提问by Ibrahim Azhar Armar

My RealEstate PHP Application have following user groups,

我的房地产 PHP 应用程序有以下用户组,

Admins, Moderators Agents

管理员、版主代理

i want to specify following permission to the following users.

我想为以下用户指定以下权限。

Admins - >

管理员 - >

  • Can Create Moderators,
  • Can Create Agents,
  • Can Insert Properties,
  • Can Update Properties,
  • Can Delete Properties
  • 可以创建版主,
  • 可以创建代理,
  • 可以插入属性,
  • 可以更新属性,
  • 可以删除属性

Hence an Admin will have all the privileges in short an Admin here will be superAdmin

因此,管理员将拥有所有权限,简而言之,这里的管理员将是超级管理员

I want to assign limited privileges to the moderator and hence to the agents.

我想将有限的权限分配给主持人,从而分配给代理。

i am confused on how to Create a Database for this and also on how to implement it in my PHP Application.

我对如何为此创建数据库以及如何在我的 PHP 应用程序中实现它感到困惑。

thank you

谢谢你

回答by

It sounds like you are going to need a role-based access control system. Developing one is not really a trivial task, so as already suggested, finding a framework or ready-made class that does the job would be a worth while start.

听起来您将需要一个基于角色的访问控制系统。开发一个实际上并不是一项微不足道的任务,因此正如已经建议的那样,找到一个框架或现成的类来完成这项工作将是一个值得开始的工作。

Role Based Access Control

基于角色的访问控制

http://www.tonymarston.net/php-mysql/role-based-access-control.html

http://www.tonymarston.net/php-mysql/role-based-access-control.html

http://www.sqlrecipes.com/database_design/fine_grained_role_based_access_control_rbac_system-3/

http://www.sqlrecipes.com/database_design/fine_grained_role_based_access_control_rbac_system-3/

http://www.sitepoint.com/forums/showthread.php?threadid=162027

http://www.sitepoint.com/forums/showthread.php?threadid=162027

You should create a table wher you have to define all type of role.

您应该创建一个表,您必须在其中定义所有类型的角色。

and one table for users

和一张用户表

relate different roles to different user Via linking two tables. and some thing like this ......

通过链接两个表将不同的角色与不同的用户相关联。还有这样的事情......

回答by Psycorpse

The way that I have done this in the past was to create a users table in the database that had an access level (Admin, Moderator, and agents).

我过去这样做的方法是在具有访问级别(管理员、版主和代理)的数据库中创建一个用户表。

Then if you have a menu system, implement a check to see what privileges are needed for what links... Admins will see all links, Moderator will only see links he/she is supposed to, and agents will only see what they are supposed to see.

然后,如果您有菜单系统,请执行检查以查看哪些链接需要哪些权限...管理员将看到所有链接,版主只会看到他/她应该看到的链接,代理只会看到他们应该看到的链接查看。

Also on the pages that you may want to restrict users you will want to check for the users access level. If they pass, they will see the page, if not, they will be redirected or a javascript error will need to pop up.

此外,在您可能想要限制用户的页面上,您还需要检查用户访问级别。如果他们通过,他们将看到该页面,否则,他们将被重定向或需要弹出 javascript 错误。

Something like the access level may do you some good to store it in a cookie as you can cut down your calls to your database.

像访问级别这样的东西可能对您有好处,将其存储在 cookie 中,因为您可以减少对数据库的调用。

Hope this helps, Mike

希望这会有所帮助,迈克