简体   繁体   English

PHP Hybrid(过程和OOO)应用程序中的访问控制和RBAC(基于角色的访问控制)

[英]Access Control and RBAC (Roles Based Access Control) In PHP Hybrid (procedural and OOO) application

I have this PHP Hybrid (procedural and OOP) application that i would like to create an RBAC for. 我有一个我想为其创建RBAC的PHP混合(过程和OOP)应用程序。

I can create the database tables (permissions, roles, users etc.), I can also find a lot of articles about the subject online but they all seem to be missing the most important part : "The resource" that we want to protect. 我可以创建数据库表(权限,角色,用户等),也可以在线找到很多有关该主题的文章,但是它们似乎都缺少最重要的部分:我们想要保护的“资源”。

Zend_ACL seems ok but my application is not MVC framework based. Zend_ACL似乎还可以,但是我的应用程序不是基于MVC框架的。

Question 1 I am wondering if the zend_acl is loosely coupled enough to use even though my entire application is not object based. 问题1我想知道即使我的整个应用程序不是基于对象的 ,zend_acl是否松散耦合足以使用

Question 2 How do i define the resources when the entire application is not object-based ? 问题2 当整个应用程序都不基于对象时,如何定义资源?

Question 3 Is there any good non-obsolete whitepaper out there that could allow me to create a role based system when dealing with an heterogeneous (procedural and OOP) system? 问题3是否有好的白皮书可以使我在处理异构(过程和OOP)系统时创建基于角色的系统?

Thanks Again 再次感谢

"Resources" are just a very generic, abstract thing, in practice it can be anything. “资源”只是一个非常普通的抽象的东西,实际上它可以是任何东西。 In a well-structured MVC architecture this resource usually corresponds to class/method names, which in turn correspond to URLs. 在结构良好的MVC架构中,此资源通常对应于类/方法名称,而类/方法名称又对应于URL。 That's just as arbitrary as anything else though. 但是,这与其他任何东西一样任意。 Even in purely procedural PHP, you can arbitrarily define resources: 即使在纯过程PHP中,您也可以任意定义资源:

$resource = 'root.foo.bar';
$user     = getCurrentUser();

if (!isAllowedToAccess($user, $resource)) {
    exit;
}

// do something that represents root.foo.bar

Keeping track of which of your code represents actions on what resource is harder without a good OO structure, but by no means impossible. 如果没有良好的OO结构,则跟踪哪个代码表示对哪些资源更困难的操作,但这绝不是不可能的。 You may simply go by file name of scripts, if those are well organized. 如果脚本的组织良好,则可以只按脚本的文件名查找。

I can't say anything specifically about Zend_ACL , but I'd be surprised if it was hardwired to OO concepts. 关于Zend_ACL ,我不能说什么,但是如果将其硬连接到OO概念,我会感到惊讶。

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

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