简体   繁体   English

Zend模块特定的ACL

[英]Zend module specific ACL

In my projects there are about 5, 6 modules 在我的项目中,大约有5,6个模块

Ex: Web - Public access, URL - www.abc.com
Admin - admin can access - admin.abc.com (Non Acl)
CP - Specific group can access - cp.abc.com (Non Acl)
pbo - Another group can access - pbo.abc.com (Acl based and implemented recently)

As given above, we recently added a module called PBO, based on ACL plugin, 如上所述,我们最近添加了一个名为PBO的模块,基于ACL插件,

each module has a specific Bootstrap file, 每个模块都有一个特定的Bootstrap文件,

But after the implementation of new module, all the other modules are going through the ACL plugin and redirect to the default page of the PBO module. 但是在实现新模块之后,所有其他模块都将通过ACL插件并重定向到PBO模块的默认页面。

This is how Privileges are set 这就是权限的设置方式

$this->acl->allow('superAdmin', 'user', array('login','logout'));
$this->acl->allow('superAdmin', 'index', 'index');
$this->acl->allow('superAdmin', 'app', 'index');

$this->acl->allow('admin', 'user', array('index','login','logout','registered'));      
$this->acl->allow('admin', 'index', 'index');
$this->acl->allow('admin', 'app', array('index', 'do-feature', 'do-delete'));

Initialize ACL in the bootstrap file 在引导程序文件中初始化ACL

public function _initAcl()
{
    //Omit the process in CLI mode
    if (php_sapi_name() != 'cli') 
    {        
        $helper = new Nexva_Controller_Action_Helper_AclPbo();
        $helper->setRoles();
        $helper->setResources();
        $helper->setPrivilages();
        $helper->setAcl();

        //Register the ACL plugin - Then it will be called automatically,whenever an     acion is called
        $frontController = Zend_Controller_Front::getInstance(); 
        $frontController->registerPlugin(new Nexva_Plugin_AclPbo());

    }
}

Is there any way to avoid calling ACL of PBO module in other modules ? 有没有办法避免在其他模块中调用PBO模块的ACL?

This is an issue with Zend Framework 1. 这是Zend Framework 1的一个问题。

Bootstraps for all Modules are always called and executed for any given Module. 始终为任何给定的模块调用和执行所有模块的Bootstraps。 This is how Zend Framework is designed. 这就是Zend Framework的设计方式。

Due to this issue, there is one really good article to read to help understand how Module Bootstrapping works in ZF and it's shortcomings. 由于这个问题,有一篇非常好的文章可以帮助理解模块Bootstrapping在ZF中的工作方式及其缺点。 It's written by Matthew Weier O'Phinney: 它由Matthew Weier O'Phinney撰写:

http://mwop.net/blog/234-Module-Bootstraps-in-Zend-Framework-Dos-and-Donts.html http://mwop.net/blog/234-Module-Bootstraps-in-Zend-Framework-Dos-and-Donts.html

From there, this site has a tutorial that talks about a solution to how to setup a "new" Bootstrap like layer that's module specific. 从那里开始,这个站点有一个教程,讨论如何设置一个特定于模块的“新”Bootstrap层的解决方案。 It also links to several sources they pulled from, most of which are worth reading (yes, there's a fair bit of reading). 它还链接到他们从中抽取的几个来源,其中大部分都值得一读(是的,有一点阅读)。

http://offshootinc.com/blog/2011/02/11/modul-bootstrapping-in-zend-framework/ http://offshootinc.com/blog/2011/02/11/modul-bootstrapping-in-zend-framework/

I hope that helps! 我希望有所帮助!

您可以做的一件事是在注册插件之前检查当前模块是否是PBO

if($frontController->getRequest()->getModuleName() == 'PBO')
$frontController->registerPlugin(new Nexva_Plugin_AclPbo());

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

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