Skip to content

kaushalkishorejaiswal/UsersACL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Created by Kaushal Kishore
Email : [email protected]
Website : http://www.kaushalkishore.com

Introduction

Zend Users ACL is a role based access control list module for Zend Framework 2, which provides the authentication process for roles for using the actions of controller. You can easily manage the permissions for controller, actions by DB using this module. It contains Roles, Resources, Role Permissions, User Role and the Permission tables for managing the infromation of roles and permissions.

Note: This module is dependent on the Users module. If you use the Users module then all the functionality of Users module and the UsersACL module will work perfectaly.

Tables Structure :

  • 		Permission Table:
    		CREATE TABLE `permission` (
    		  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    		  `permission_name` varchar(45) NOT NULL,
    		  `resource_id` int(10) unsigned NOT NULL,
    		  PRIMARY KEY (`id`)
    		);
    		
  • <li>
    	<pre>
    	<b>Resource Table:</b>
    	CREATE TABLE `resource` (
    	  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    	  `resource_name` varchar(50) NOT NULL,
    	  PRIMARY KEY (`id`)
    	);
    	</pre>
    </li>
    
    <li>
    	<pre>
    	<b>Role Table:</b>
    	CREATE TABLE `role` (
    	  `rid` int(10) unsigned NOT NULL AUTO_INCREMENT,
    	  `role_name` varchar(45) NOT NULL,
    	  `status` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
    	  PRIMARY KEY (`rid`)
    	);
    	</pre>
    </li>
    
    <li>
    	<pre>
    	<b>Role Permission Table:</b>
    	CREATE TABLE `role_permission` (
    	  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    	  `role_id` int(10) unsigned NOT NULL,
    	  `permission_id` int(10) unsigned NOT NULL,
    	  PRIMARY KEY (`id`)
    	)
    	</pre>
    </li>
    
    <li>
    	<pre>
    	<b>User Role Table:</b>
    	 CREATE TABLE `user_role` (
    	  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    	  `user_id` int(10) unsigned NOT NULL,
    	  `role_id` int(10) unsigned NOT NULL,
    	  PRIMARY KEY (`id`)
    	)
    	</pre>
    </li>
    

Tables Data and its descriptions :

  • 		Roles : It contains all the Roles for the ZF2 site users. 
    		Sample data :
    		+-----+-----------+--------+
    		| rid | role_name | status |
    		+-----+-----------+--------+
    		|   1 | Manager   | Active |
    		|   2 | Employee  | Active |
    		|   3 | Customer  | Active |
    		|   4 | Guest     | Active |
    		+-----+-----------+--------+
    		
  • 		Resources : It contains all the controllers name with their full path.
    		+----+------------------------------+
    		| id | resource_name                |
    		+----+------------------------------+
    		|  1 | Application\Controller\Index |
    		|  2 | Album\Cotroller\Album        |
    		|  3 | Users\Controller\Index       |
    		+----+------------------------------+
    		
  • 		Permissions : It contains all the actions name and resource_id for their 
    		actions. Currently it contains all the actions of Application 
    		Index Controller.
    		+----+-----------------+-------------+
    		| id | permission_name | resource_id |
    		+----+-----------------+-------------+
    		|  1 | index           |           1 |
    		|  5 | list            |           1 |
    		|  6 | add	       |           1 |
    		|  7 | edit            |           1 |
    		|  8 | delete          |           1 |
    		|  9 | update          |           1 |
    		+----+-----------------+-------------+
    		
  • 		User Role : It contains all the roles of the users, 
    		where user_id is the primary key of the users.
    		+----+---------+---------+
    		| id | user_id | role_id |
    		+----+---------+---------+
    		|  1 |       1 |       1 |
    		|  2 |       2 |       2 |
    		|  3 |       3 |       3 |
    		|  4 |       4 |       4 |
    		+----+---------+---------+
    		
  • 		Role Permissions : It contails all the permission for the role, 
    		where role_id is the foreign key of role table and permission_id 
    		is the foreign key of permission table.
    		+----+---------+---------------+
    		| id | role_id | permission_id |
    		+----+---------+---------------+
    		|  1 |       1 |             1 |
    		|  9 |       1 |             5 |
    		| 10 |       1 |             6 |
    		| 11 |       2 |             7 |
    		| 12 |       3 |             8 |
    		| 13 |       4 |             9 |
    		| 14 |       1 |             7 |
    		+----+---------+---------------+
    		

Functionality of the UsersACL Module:

  • Role base page access control
  • All the things are handled by DB

Installation

  • Clone the UsersACL Module into your vendor folder
  • Enabling it in your application.config.phpfile.
  • Import the UsersACLData.sql file in your database, located in data folder of UsersACL module

Enable the module in application.config.php

<?php
return array(
    'modules' => array(
        // ...
        'UsersACL',
    ),
    // ...
);

About

Users Access Control List for Zend FrameWork 2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages