Code Monkey home page Code Monkey logo

kohana-rbac's Introduction

Role Based Access Control for Kohana3

rbac table

Usage

  1. enable rbac module in bootstrap.php (auth module is needed)

  2. install install.sql under rbac directory (replace '{table_prefix}' to your own table_prefix)

  3. if you haven't created user , create first , and assign a role for this user

  4. create rules in action's comment using @rule tag like this /**

    • @rule edit node
    • @rule edit node (owner)|$item->user_id == $user->id */ public function action_edit() { $node = ORM::factory('node')->find($this->request->param('id')); Rbac::check($node); //... } in the second rule , there is a "|", below which is an expression , $item is $node here.
  5. if you don't have login form , you can use Auth::force_login like this public function action_login() { // suppose you just created an user whose email is [email protected] Auth:instance()->force_login('[email protected]'); // if you want to log out // Auth::install()->logout(); } then browser this url to perform login

  6. go to http://localhost/path/to/admin/rbac it will show a table if everything works well, you can check and uncheck for special roles. pretty easy and directly

Tips

  1. admin has all priviledges.

  2. if you visit /path/to/admin/rbac , and it shows 'sorry , but you are not allowed to access this page', you can comment Rbac::check($node) in controller/admin/rbac.php temporary.

kohana-rbac's People

Contributors

limboy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.