github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

NoamB / acts_as_permissible

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 38
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (2)
  • Wiki (2)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (2)
    • 1.0.1
    • 1.0
Sending Request…
Click here to lend your support to: acts_as_permissible and make a donation at www.pledgie.com ! Edit Pledgie Setup

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

An activerecord based RBAC permissions system. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Fixing bug entered in last commit: generating the plugin with the 
--skip-roles option creates a bad 'permissions_hash' method. 
NoamB (author)
Fri Aug 08 07:07:51 -0700 2008
commit  46b65fee928193a5ad210b9b13d0129cd607974e
tree    92828ec5ec0000b129767dd913e761ad24bdbb99
parent  a3f25487398f59ef12f43f28d77fe1cda6812e80
acts_as_permissible /
name age
history
message
file .gitignore Fri May 09 06:43:36 -0700 2008 added main gitignore. [NoamB]
file MIT-LICENSE Fri May 09 06:38:01 -0700 2008 added current plugin source files. [NoamB]
file README Fri May 16 07:14:30 -0700 2008 update README. [NoamB]
file Rakefile Fri May 09 16:19:35 -0700 2008 changed spelling error permissable to permissible. [NoamB]
directory generators/ Fri Aug 08 07:07:51 -0700 2008 Fixing bug entered in last commit: generating t... [NoamB]
file init.rb Sat May 10 09:33:59 -0700 2008 replaced config/initializer with plugin init. [NoamB]
file install.rb Fri May 09 06:38:01 -0700 2008 added current plugin source files. [NoamB]
directory lib/ Fri May 09 08:30:28 -0700 2008 added the lib dir. [NoamB]
directory tasks/ Fri May 09 16:19:35 -0700 2008 changed spelling error permissable to permissible. [NoamB]
directory test/ Fri May 09 16:19:35 -0700 2008 changed spelling error permissable to permissible. [NoamB]
file uninstall.rb Fri May 09 06:38:01 -0700 2008 added current plugin source files. [NoamB]
README
ActsAsPermissible
=================

Source:
http://github.com/NoamB/acts_as_permissible/tree/master
More information at:
http://github.com/NoamB/acts_as_permissible/wikis

This plugin enables any activerecord model to have permissions.
It provides a set of methods for querying the model's permissions.
In addition, the plugin can generate roles support, which turns in into a full RBAC (Role Based Access Control) 
solution.

Any model which includes the line "acts_as_permissible" can have permissions, and with roles support it can also have 
roles which in turn have their own permissions.
Roles can also belong to roles, which creates a sort of inheritance hierarchy.
When permissions are calculated, the model's permissions are merged with the model's role permissions (if any), which in 
turn are merged with the role's roles permissions, until a finite permissions hash is generated.

In the case of identical keys, a false value overrides a true value, A true value overrides a nil value, and a nil value 
is false.

Setup
=====
script/generate permissible <PermissionModelName> [RoleModelName]

The role model name is optional. If you do not want the roles support generated, use the --skip-roles option.

examples: script/generate permissible Permission Role
      script/generate permissible Permission Group
      script/generate permissible Allowance --skip-roles

use --skip-migration if you don't want a migration created for the permissions model.

use --rspec to force rspec tests installed (currenty these are the only ones available).

Add any permissions you want to your permissions table.
Add any roles you want to your roles table.
Add user->role relationships in your roles_memberships table.
Add role->role relationships in your roles_memberships table.

Usage
=====

  class User < Activerecord::Base
    acts_as_permissible
  end

Now a user will have the following methods:

  @user.permissions_hash() # => {:view_something => true, :delete_something => false}

  @user.has_permission?("view_something") # => true
  @user.has_permission?("view_something", "delete_something") # => false
  @user.has_permission?("delete_something") # => false
  @user.has_permission?("create_something") # => false

  @user.permissions_hash() # => {:view_something => true, :delete_something => false}
  @user.permissions << Permission.new(:action => "new_thing", :granted => true)
  @user.permissions_hash() # => {:view_something => true, :delete_something => false}
  @user.reload_permissions!() # => {:view_something => true, :delete_something => false, :new_thing => true}
  @user.permissions_hash() # => {:view_something => true, :delete_something => false, :new_thing => true}
  # this is useful for getting the hash again into memory after the permissions table was updated.

And with roles support:

  @user.in_role?("publisher") # => true
  @user.in_role?("publisher","advertiser") # => false
  @user.in_any_role?("publisher","advertiser") => true
  @user.full_permissions_hash() # will return a merged hash of user and roles permissions.

Copyright (c) 2008 Noam Ben-Ari, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server