dmitrymomot/kohana-acl

This package is abandoned and no longer maintained. No replacement package was suggested.

Kohana v3 ACL

3.3.1 2014-01-17 21:41 UTC

This package is auto-updated.

Last update: 2022-05-12 17:17:20 UTC


README

#Kohana ACL

ACL module for Kohana >= 3.3 based on Wouterrr/ACL + Wouterrr/A2

###Dependencies

###Installation

First off, download and enable the module in your bootstrap.

Add the necessary tables and fields in the database using migrations:

$ ./minion db:migrate --module=kohana-acl

###Settings

..........

###Usage

####Simple usage without file config or database Add resource

ACL::instance()->add_resource('news');

Add roles

ACL::instance()->add_role('guest');
ACL::instance()->add_role('member');
ACL::instance()->add_role('editor');
ACL::instance()->add_role('admin');

Allow "guest" to "view" the news

ACL::instance()->allow('guest', 'news', 'view');

Allow "member" to "comment" on "news"

ACL::instance()->allow('member', 'news', 'comment');

Allow "editor" to do anything, except "delete" news

ACL::instance()->allow('editor', 'news');
ACL::instance()->deny('editor', 'news', 'delete');

Allow "admin" to do anything

ACL::instance()->allow('admin');

Check permissions for current user

ACL::check('news', 'edit'); // return boolean value

Check permissions for any role

ACL::instance()->is_allowed('guest', 'news', 'comment');
ACL::instance()->is_allowed('editor', 'news', 'add');
ACL::instance()->is_allowed('admin', 'news', 'delete');

###Drivers

####Use Auth as driver See demo application or use default driver which is wrapper for Auth.

####Creating new driver Class must implement interface ACL_Auth_Interface. For example see default driver