Zend_Acl Quickstart

Saturday, August 9th, 2008

This screencast covers the usage of Zend_Acl in combination with Zend_Auth. Zend_Acl will be used to implement a static “Access Control List” in the existing sample application which was created in the Zend_Auth screencast. At the bottom of this page you find the sources and relevant links.

 
icon for podpress  Zend_Acl Quickstart Screencast [30:46m]: Play Now | Play in Popup | Download

Screencast licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Webnews
  • MisterWong
  • Y!GG
  • Technorati
  • Facebook
  • Furl
  • Google Bookmarks
  • Slashdot
  • Ask
  • Hype
  • Netscape
  • Readster
  • YahooMyWeb

Tags: , , ,

10 Responses to “Zend_Acl Quickstart”

  1. Thomas Says:

    Thank you so much for this very understandable screencast. It should be added to the zend framework official documentation!
    I’m on the watchout for more like these!

  2. Mike Rötgers Says:

    Thank you for your feedback. More will follow soon.

  3. Genio Salama Says:

    Thank you so so so so much , I`m practitioner developer and I should understand how ZF works better , u gave me such a nice clue :)

  4. Pino Says:

    Thank you very much. This is a really good tutorial…
    But how would the My_Controller_Plugin_Acl’s preDispatch()-method change if I have a site that does also have modules.
    So for exampla I have the default-module with two actions:
    1. IndexAction - everybody can access this
    2. MemberAction - just Members can access this

    And a CMS-module with some actions, but this is just for admins.

    I guess that the parameters whithin call to $asl->isAllowed() would change. But to what? Do I have to check for modules and contollers?

  5. Mike Rötgers Says:

    I named my resources like my controllers. You can change that to a naming scheme like “modulename_controllername”.
    The plugin would then change to this:

    class My_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
    {
        public function preDispatch(Zend_Controller_Request_Abstract $request)
        {
            if (Zend_Auth::getInstance()->hasIdentity())
            {
                $role = Zend_Auth::getInstance()->getStorage()->read()->role;
            }
            else
            {
                $role = 'guest';
            }
           
            $acl = new My_Acl();
           
            if (!$acl->isAllowed(
                $role,
                $request->getModuleName() . '_' . $request->getControllerName(),
                $request->getActionName()
            ))
            {
                throw new Zend_Exception('Access Denied!');
            }
        }
    }
  6. Pino Says:

    Thank you very much for this quick response.

  7. Alican Says:

    Are you planning another screencasts for other components, I think Zend_Lucene and Zend_Translate would be great.
    Also this is great tutorial, thank you for your efforts.

  8. Mike Rötgers Says:

    Yes, new screencasts will follow as soon as my company’s newest project is up and running. Topics will probably be Zend_Translate with gettext and Continuous Integration with phpUnderControl.

  9. Thimo Says:

    Hi,

    I really rarely write a comment but i think you have earned it!
    Thanks for this really great tutorial!
    It’s really easy now^^ And your debate is really good, also for “not-english-speeking-persons” ;)

    Thanks allot!

  10. Mike Says:

    This is a very excellent screencast!! Thanks so much for providing a useful example with clear explanations as to why you are doing each step and taking nothing for granted. I look forward to you future screencasts!

    Thanks!
    -Mike

Leave a Reply