{"id":14987269,"url":"https://github.com/firoz-ahmad-likhon/codeigniter-role-base-access-control","last_synced_at":"2025-04-06T18:16:38.732Z","repository":{"id":44430836,"uuid":"154789372","full_name":"firoz-ahmad-likhon/codeigniter-role-base-access-control","owner":"firoz-ahmad-likhon","description":"CodeIgniter Role Base Access Control library is an easy understandable, comprehensive and convenient way to manage users.","archived":false,"fork":false,"pushed_at":"2024-11-22T04:47:32.000Z","size":14,"stargazers_count":70,"open_issues_count":7,"forks_count":43,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-30T16:13:34.444Z","etag":null,"topics":["codeigniter","php","rbac","role-based-access-control"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firoz-ahmad-likhon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-26T06:44:43.000Z","updated_at":"2024-08-22T04:03:38.000Z","dependencies_parsed_at":"2024-12-16T18:34:53.061Z","dependency_job_id":"de7b7350-5511-462a-8536-bfacf7a852b1","html_url":"https://github.com/firoz-ahmad-likhon/codeigniter-role-base-access-control","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"a02d55c56ba2e8cbdfeba9d4c9db329af2360985"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firoz-ahmad-likhon%2Fcodeigniter-role-base-access-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firoz-ahmad-likhon%2Fcodeigniter-role-base-access-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firoz-ahmad-likhon%2Fcodeigniter-role-base-access-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firoz-ahmad-likhon%2Fcodeigniter-role-base-access-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firoz-ahmad-likhon","download_url":"https://codeload.github.com/firoz-ahmad-likhon/codeigniter-role-base-access-control/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526765,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeigniter","php","rbac","role-based-access-control"],"created_at":"2024-09-24T14:14:21.515Z","updated_at":"2025-04-06T18:16:38.713Z","avatar_url":"https://github.com/firoz-ahmad-likhon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Role Base Access Control\n\nIt is a library for CodeIgniter to manage role base access control.\n\n### Requirement ###\n* CodeIgniter Version \u003e= 3\n* PHP Version \u003e= 5.6\n\n### Installation ###\n\n* Download/Clone the repository\n* Put all files into your project directory respectively.\n* Ensure the session library and auth_helper are auto loaded in config/autoload.php:\n\n\n        $autoload['libraries'] = array('session');\n        $autoload['helper'] = array('auth_helper', 'url');\n    \n* You can set login as a default controller in config/route.php.\n\n\n        $route['default_controller'] = 'login';\n\n* Run sql file attached with this repository. The default username and password are: admin\n\nNow you are ready to browse the application.\n\n### Manage ##\n**Add permission:**\n\nName format: **method_name-controller_name**\n _Example: if the controller name is 'roles; and 'edit' is a method then name will be 'edit-roles'_\n               \n    $this-\u003ePermission-\u003eadd([\n        'name' =\u003e 'add-roles',\n        'display_name' =\u003e 'Create Role',\n        'status' =\u003e 1,\n    ]);\n              \n\n**Add role:**\n  \n    $this-\u003eRole-\u003eadd([\n        'name' =\u003e 'editor',\n        'display_name' =\u003e 'editor',\n        'description' =\u003e 'Editor can edit and   publish posts',\n        'status' =\u003e 1,\n    ]);\n\n**Assign permissions with role:**\n\n_$permissions will be a permission id or an array of permission id_\n\n    $this-\u003eRole-\u003eaddPermissions($role_id, $permissions);\n\nExample:\n\n    $this-\u003eRole-\u003eaddPermissions(1, [2, 3]);\n**Add User:**\n\n\n    $this-\u003eUser-\u003eadd([\n        'name' =\u003e 'Likhon',\n        'username' =\u003e 'likhon',\n        'password' =\u003e password_hash('admin',   PASSWORD_BCRYPT),,\n        'status' =\u003e 1,\n    ]);\n               \n\n**Assign roles with user:**\n\n_$roles will be a role id or an array of role id_\n\n    $this-\u003eUser-\u003eaddRoles($user_id, $roles);\n\nExample:\n\n    $this-\u003eUser-\u003eaddRoles(2, [2, 3]);\n### Role base access control ###\n\nRole base access control is a library that makes decision for access on the permissions. This library can handle multi roles.\nTo enable authentication put these line in controller's construction method:\n\n    $this-\u003eload-\u003elibrary(['auth']);\n    $this-\u003eauth-\u003eroute_access();\n    \nIf you want to authenticate only some methods of a controller then use\n\n    $this-\u003eauth-\u003eonly($methods)\n    \nUses: \n\n    $this-\u003eauth-\u003eonly(['edit-posts', 'publish-posts'])\nOr if you need to not check authentication for some methods then use:\n\n    $this-\u003eauth-\u003eexcept($methods)\n\nUses: \n\n    $this-\u003eauth-\u003eexcept(['add-posts'])\nHelper\n======\nCheck if current user is logged in.\n\n    check()\n    \nCheck if current user has a permission by its name.\n\n    can($permissions)\n    \nUses:\n\n    if( can('edit-posts') ) {}\n    if( can(['edit-posts', 'publish-posts']) ) {}\n\nChecks if the current user has a role by its name.\n\n    hasRole($roles)\n\nUses\n\n    if( hasRoles(['admin', 'editor']) ) {}\n    if( hasRoles('subscriber') ) {}    \nMethod\n======\nCheck login status: return true|false\n  \n    $this-\u003eauth-\u003eloginStatus()\n\nGuest user check: return true|false\n\n    $this-\u003eauth-\u003eguest()\n   \nRead authenticated user ID\n\n    $this-\u003eauth-\u003euserID()\n  \nRead authenticated user Name\n   \n    $this-\u003eauth-\u003euserName()\n\nRead authenticated user roles\n\n    $this-\u003eauth-\u003eroles()\n\nRead authenticated user permissions\n\n    $this-\u003eauth-\u003epermissions()\n    \nLogout\n\n    $this-\u003eauth-\u003elogout()","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiroz-ahmad-likhon%2Fcodeigniter-role-base-access-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiroz-ahmad-likhon%2Fcodeigniter-role-base-access-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiroz-ahmad-likhon%2Fcodeigniter-role-base-access-control/lists"}