bare-acl by sudheer
TRANSCRIPT
-
8/9/2019 bare-acl by Sudheer
1/16
Introduction To Bare_Acl
Sudheer SatyanarayanaBinary Vibes Information Technologies Pvt. Ltd.
http://projects.binaryvibes.co.in/projects/show/barehttp://binaryvibes.co.inhttp://techchorus.net
http://binaryvibes.co.in/http://techchorus.net/http://techchorus.net/http://binaryvibes.co.in/ -
8/9/2019 bare-acl by Sudheer
2/16
What Is Bare?
Bare bones framework written byBangaloreans
Written to fill the gap created by libraries andframeworks
Keeping simplicity in mind
Currently has one component - Bare_Acl
-
8/9/2019 bare-acl by Sudheer
3/16
What Is Acl?
Access Control List
Who gets what?
RBAC Role Based Access Control
-
8/9/2019 bare-acl by Sudheer
4/16
Downloading Bare_Acl
http://binaryvibes.co.in/downloads/
Tar and Zip archives available
http://binaryvibes.co.in/downloads/http://binaryvibes.co.in/downloads/ -
8/9/2019 bare-acl by Sudheer
5/16
Using Bare_Acl
Manually using require_once
Autoloading plays well with Zend Frameworkand other popular PHP auto loaders
Roll your own autoloader
-
8/9/2019 bare-acl by Sudheer
6/16
Acl Example - Privileges
Create articles
Publish articles Edit articles
Delete articles
-
8/9/2019 bare-acl by Sudheer
7/16
Acl Example - Roles
editor
reporter
-
8/9/2019 bare-acl by Sudheer
8/16
Acl Example - Rules
Reporter can create and publish articles
Editor can create, publish, edit and deletearticles
-
8/9/2019 bare-acl by Sudheer
9/16
Acl Example Building Acl
$acl = new Bare_Acl;
$acl->addPrivilege('create articles');$acl->addPrivilege('publish articles');$acl->addPrivilege('edit articles');$acl->addPrivilege('delete articles');
$acl->addRole('reporter');$acl->addRole('editor');
-
8/9/2019 bare-acl by Sudheer
10/16
Acl Example Building Acl
$acl->allow('reporter', 'create articles');$acl->allow('reporter', 'publish articles');
$acl->allow('editor', 'create articles');$acl->allow('editor', 'publish articles');$acl->allow('editor', 'edit articles');
$acl->allow('editor', 'delete articles');
-
8/9/2019 bare-acl by Sudheer
11/16
Acl Example Querying Acl
if ($acl->isAllowed(array('reporter'), 'create articles')) {echo PHP_EOL . " Reporter is allowed to createarticles";}
if ($acl->isAllowed(array('reporter'), 'edit articles')) {
echo PHP_EOL . " Reporter is allowed to edit articles";} else {
echo PHP_EOL . " Reporter is NOT allowed to editarticles";}
Reporter is allowed to create articlesReporter is NOT allowed to edit articles
-
8/9/2019 bare-acl by Sudheer
12/16
Acl Assertions
Assert = affirm, declare with assurance
New Rules Edit own articles
Edit all articles
-
8/9/2019 bare-acl by Sudheer
13/16
Acl Assertions Creating TheAssertion Object
class ownArticleAssertion implementsBare_Acl_AssertInterface{
public function assert(Bare_Acl $acl){//Write code here to test if the user
has access to edit this article
return true;}
}
-
8/9/2019 bare-acl by Sudheer
14/16
Acl Assertions Querying The Acl
$assertion = new ownArticleAssertion;if ($acl->isAllowed('reporter', null, $assertion)) {
echo PHP_EOL . "Reporter has access to edit thearticle";
} else {echo PHP_EOL . "Reporter does NOT have access toedit the article";}
-
8/9/2019 bare-acl by Sudheer
15/16
Contributions Are Welcome
Liberal new BSD license
CLA required
Other components are welcome
-
8/9/2019 bare-acl by Sudheer
16/16
Thank You