Skip to content

RBACan is a Role-based access control tool to control user access to the functionnalities of your application

License

Notifications You must be signed in to change notification settings

hamdi777/RBACan

Repository files navigation

Rbacan

a Role-based access control tool to control user access to the functionnalities of your application

Installation

Add this line to your application's Gemfile:

gem 'rbacan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rbacan

Usage

run rails generate rbacan:install

copy the content in the generated file db/copy_to_seed.rb in your seeds.rb file you have there all the tools you need to create you roles and permissions

You might need to configure you user class_name if you're using a different class_name for the user, go to rbacan.rb in your initializers folder and make your change

    Rbacan.configure do |config|
    config.permittable_class = "YOUR USER CLASS_NAME"
    end

if you want to assign a role to a user it is simple you just have to do so:

user = current_user

user.assign_role(role_name)

to remove a role from user do this:

user.remove_role(role_name)

now when you want to test if a user have access to a functionnality use this:

user.can?(permission_name)

add this line to your user model:

include Rbacan::Permittable

run:

    rails db:migrate
    rails db:seed

enjoy :D

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hamdi777/RBACan. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rbacan project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

RBACan is a Role-based access control tool to control user access to the functionnalities of your application

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •