Project

rbac-ruby

0.0
The project is in a healthy, maintained state
Use dynamicly configurable RBAC system to control access to your application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 6.1, < 9.0
>= 6.1, < 9.0
~> 0.2.0
 Project Readme

RBAC Ruby

A simple way to manage access and visibillity scopes to objects in your Rails applications.

Installation

Add this line to your application's Gemfile:

gem 'rbac-ruby'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install rbac

Requirements

Your application should contain model User with methods current_user which will return attributes to filtering your objects.

Usage

Write config file with buissiness logic (see examples). Include Rbac modules into your application. And have fun :)

EXAMPLE:

Models:

  • HelpdeskSystem
  • Project
  • Request
  • User (can be abstract model)

Relations:

  • HelpdeskSystem 1-M Project
  • Project 1-M Request

Roles:

  • admin (can see and modify each object in application)
  • supported (can see and modify each object in region)
  • guest (can see and modify own request into projects which available in region)
# For example class User.
# Cause User.current_user IS REQUIRED for this gem
class User
  attr_reader :userid, :region, :role
  thread_mattr_accessor :current_user

  def initialize(opts)
    @userid = opts[:userid]
    @region = opts[:region]
    @role = opts[:role]
  end
end

Define a RBAC Routes file which configure access to controllers for autheticated users and include to your controllers and write custom buissiness logic.

Define a RBAC Scopes file which containe logic how our application will filter records and include Rbac::Filterer into app/models/application.rb (to include filtering method to all models) OR into specific model to use filtation only here. Now you can call Model.filtered (e.g. HelpdeskSystem.filtered, Project.filtered, Request.filtered)