All Projects → firoz-ahmad-likhon → codeigniter-role-base-access-control

firoz-ahmad-likhon / codeigniter-role-base-access-control

Licence: MIT License
CodeIgniter Role Base Access Control library is an easy understandable, comprehensive and convenient way to manage users.

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to codeigniter-role-base-access-control

react-abac
Attribute Based Access Control for React
Stars: ✭ 54 (-8.47%)
Mutual labels:  rbac, role-based-access-control
rbac-react-redux-aspnetcore
A starter template for creating JWT token from ASP.NET Core API project and applying that JWT token authentication on React application
Stars: ✭ 54 (-8.47%)
Mutual labels:  rbac, role-based-access-control
deflek
index and API RBAC for Elasticsearch and Kibana via reverse proxy. DEPRECATED
Stars: ✭ 13 (-77.97%)
Mutual labels:  rbac, role-based-access-control
rurality
开源运维平台设计及开发样例、CMS、RBAC、python开发教程、管理系统设计及开发样例、jenkinsfile(pipeline)/ansible使用教程,一切想到的,想不到的,应有尽有
Stars: ✭ 51 (-13.56%)
Mutual labels:  rbac
rbac core
(Moved to https://github.com/rails-engine/role_core) A Rails engine providing essential industry of Role-based access control
Stars: ✭ 15 (-74.58%)
Mutual labels:  rbac
ParkCatcher
Find a free parking in the nearest residential street when driving in Montréal. A Montréal Open Data project.
Stars: ✭ 32 (-45.76%)
Mutual labels:  codeigniter
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (-13.56%)
Mutual labels:  rbac
Ecommerce-CodeIgniter
An ecommerce CMS, very simple to use. Best for online shopping sites
Stars: ✭ 18 (-69.49%)
Mutual labels:  codeigniter
Go-Gin-Api
基于golang开源框架 gin封装的api框架
Stars: ✭ 42 (-28.81%)
Mutual labels:  rbac
CodeIgniter4-Cart-Module
A basic port of the CodeIgniter 3 cart library for CodeIgniter 4.
Stars: ✭ 31 (-47.46%)
Mutual labels:  codeigniter
Casbin4D
An authorization library that supports access control models like ACL, RBAC, ABAC in Delphi
Stars: ✭ 25 (-57.63%)
Mutual labels:  rbac
article-translation
CodeIgniter article translation. CodeIgniter 文章翻译项目。
Stars: ✭ 25 (-57.63%)
Mutual labels:  codeigniter
vue-php-admin
RBAC通用角色权限管理系统, 前后端分离架构, 基于 vue-element-admin 和 PHP CodeIgniter RESTful 实现
Stars: ✭ 4 (-93.22%)
Mutual labels:  codeigniter
yqdoc
基于语雀API开发的文档系统
Stars: ✭ 64 (+8.47%)
Mutual labels:  codeigniter
ForgeIgniter-CI-3.x
Friendly open source CMS forged on Codeigniter 3
Stars: ✭ 26 (-55.93%)
Mutual labels:  codeigniter
hulk-template
为 CodeIgniter 框架增加视图继承功能,不改变原有视图编写方式,无缝增加视图继承功能。
Stars: ✭ 17 (-71.19%)
Mutual labels:  codeigniter
aranya
Control all kinds of devices with Kubernetes
Stars: ✭ 16 (-72.88%)
Mutual labels:  rbac
cat
CAT is a computer-based online test application powered by Codeigniter, jquery. Simple and easy to use
Stars: ✭ 72 (+22.03%)
Mutual labels:  codeigniter
ci4-album
🔥 CodeIgniter 4 example Album module uses Domain Driven Design Architecture with Tactical Pattern
Stars: ✭ 67 (+13.56%)
Mutual labels:  codeigniter
rbac
基于rbac设计的权限管理系统
Stars: ✭ 27 (-54.24%)
Mutual labels:  rbac

Role Base Access Control

It is a library for CodeIgniter to manage role base access control.

Requirement

  • CodeIgniter Version >= 3
  • PHP Version >= 5.6

Installation

  • Download/Clone the repository

  • Put all files into your project directory respectively.

  • Ensure the session library and auth_helper are auto loaded in config/autoload.php:

      $autoload['libraries'] = array('session');
      $autoload['helper'] = array('auth_helper', 'url');
    
  • You can set login as a default controller in config/route.php.

      $route['default_controller'] = 'login';
    
  • Run sql file attached with this repository. The default username and password are: admin

Now you are ready to browse the application.

Manage

Add permission:

Name format: method_name-controller_name Example: if the controller name is 'roles; and 'edit' is a method then name will be 'edit-roles'

$this->Permission->add([
    'name' => 'add-roles',
    'display_name' => 'Create Role',
    'status' => 1,
]);

Add role:

$this->Role->add([
    'name' => 'editor',
    'display_name' => 'editor',
    'description' => 'Editor can edit and   publish posts',
    'status' => 1,
]);

Assign permissions with role:

$permissions will be a permission id or an array of permission id

$this->Role->addPermissions($role_id, $permissions);

Example:

$this->Role->addPermissions(1, [2, 3]);

Add User:

$this->User->add([
    'name' => 'Likhon',
    'username' => 'likhon',
    'password' => password_hash('admin',   PASSWORD_BCRYPT),,
    'status' => 1,
]);

Assign roles with user:

$roles will be a role id or an array of role id

$this->User->addRoles($user_id, $roles);

Example:

$this->User->addRoles(2, [2, 3]);

Role base access control

Role base access control is a library that makes decision for access on the permissions. This library can handle multi roles. To enable authentication put these line in controller's construction method:

$this->load->library(['auth']);
$this->auth->route_access();

If you want to authenticate only some methods of a controller then use

$this->auth->only($methods)

Uses:

$this->auth->only(['edit-posts', 'publish-posts'])

Or if you need to not check authentication for some methods then use:

$this->auth->except($methods)

Uses:

$this->auth->except(['add-posts'])

Helper

Check if current user is logged in.

check()

Check if current user has a permission by its name.

can($permissions)

Uses:

if( can('edit-posts') ) {}
if( can(['edit-posts', 'publish-posts']) ) {}

Checks if the current user has a role by its name.

hasRole($roles)

Uses

if( hasRoles(['admin', 'editor']) ) {}
if( hasRoles('subscriber') ) {}    

Method

Check login status: return true|false

$this->auth->loginStatus()

Guest user check: return true|false

$this->auth->guest()

Read authenticated user ID

$this->auth->userID()

Read authenticated user Name

$this->auth->userName()

Read authenticated user roles

$this->auth->roles()

Read authenticated user permissions

$this->auth->permissions()

Logout

$this->auth->logout()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].