Ha! Een nieuwe rails plugin: Roleify, a rails authorization plugin.
Deze plugin komt uit een lopend project van ons en ik dacht zo, we zullen die maar ineens opengooien. Ik heb er nog wel wat plannen mee, dus het zal zeker hier en daar nog wijzigen.
Here goes:
A Rails authorization plugin
Dependent on Clearance (should be configurable in the future though)
Make sure your User object has a “role” attribute (String).
Roleify::Role.configure("role_a", "role_b") do
{
:role_a => { :issues => :all },
:role_b => { :issues => "index" }
}
end
In the example above “role_a” and “role_b” are the roles you are defining. The block contains the rules for these roles. There is no need to define an “admin” role, since it’s added by default.
class IssuesController < ActionController::Base
include Clearance::Authentication
include Roleify::RoleifyableController
end
class User < ActiveRecord::Base
include Clearance::User
include Roleify::RoleifyableModel
end
Constants:
Roleify::Role::ADMIN
Roleify::Role::ROLE_A
Roleify::Role::ROLE_B
Named scopes are automatically added:
User.admins
User.role_as
User.role_bs
Methods:
User.admin?
User.role_a?
User.role_b?
Questions? Shoot!
blog comments powered by Disqus