thelinuxlich-aegis 1.1.8 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +40 -3
  2. data/VERSION +1 -1
  3. data/thelinuxlich-aegis.gemspec +2 -3
  4. metadata +3 -4
  5. data/:test +0 -0
@@ -13,12 +13,49 @@ Alternatively, use
13
13
  sudo gem install thelinuxlich-aegis
14
14
 
15
15
  == Changes in this fork
16
- Now you can set the permission prefix with your locale(default is 'may')
16
+ WARNING! Opinionated stuff!
17
+ Now you can set the permission prefix, admin and crud verbs with your locale(default is 'may','admin','read','write','update' and 'destroy', respectively)
17
18
  Example: in locale/en.yml:
18
19
  aegis:
19
- permission_prefix: 'should'
20
+ permission: 'should'
21
+ admin: 'manage'
22
+ read: 'access'
23
+ write: 'insert'
24
+ update: 'update'
25
+ destroy: 'delete'
26
+
27
+ And then you can verify authorization with current_user.should_access_posts?
28
+
29
+ Also, there is a class method you can put on ApplicationController(or anything that extends ActionController::Base) to automatically add before_filter to all REST actions verifying authorization:
30
+ authorize_first!(:current_user, options)
31
+
32
+ First parameter is a string containing the method to access the current user on your favorite authentication gem, second parameter accepts :except => [ARRAY_OF_CONTROLLER_NAMES]
33
+
34
+ The user class now can call has_role :special_permissions => true, and it will add a has_many association with special_permissions to really customize what every role can access.
35
+
36
+ In Permissions class, you can add restful_permissions!(:except => [ARRAY_OF_CONTROLLER_NAMES]) and it will add the 4 crud verbs to verify permission with every role, first verifying if the current user has admin access then verifying in SpecialPermission association.
37
+ Example: Imagine we have a controller called Posts. It will add the permission methods may_read_posts?, may_write_posts?, may_update_posts?, may_destroy_posts?, all customizable with locales.
38
+
39
+ For special permissions, you'll also need a table for it. Create a migration like this:
40
+ class CreateSpecialPermissions < ActiveRecord::Migration
41
+ def self.up
42
+ create_table :special_permissions do |t|
43
+ t.integer :user_id
44
+ t.string :permission_module
45
+ t.boolean :permission_read, :default => false
46
+ t.boolean :permission_write, :default => false
47
+ t.boolean :permission_destroy, :default => false
48
+ t.boolean :permission_update, :default => false
49
+ t.timestamps
50
+ end
51
+ end
52
+
53
+ def self.down
54
+ drop_table :special_permissions
55
+ end
56
+ end
20
57
 
21
- And then you can verify authorization with current_user.should_edit_posts?
58
+ Until I fix the generator, the migration part is manual, unfortunately :(
22
59
 
23
60
  == Example
24
61
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.8
1
+ 1.1.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{thelinuxlich-aegis}
8
- s.version = "1.1.8"
8
+ s.version = "1.1.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["thelinuxlich"]
12
- s.date = %q{2010-03-24}
12
+ s.date = %q{2010-03-29}
13
13
  s.description = %q{Aegis is a role-based permission system, where all users are given a role. It is possible to define detailed and complex permissions for each role very easily.}
14
14
  s.email = %q{thelinuxlich@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
- ":test",
21
20
  "MIT-LICENSE",
22
21
  "README.rdoc",
23
22
  "Rakefile",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 8
9
- version: 1.1.8
8
+ - 9
9
+ version: 1.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - thelinuxlich
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-24 00:00:00 -03:00
17
+ date: 2010-03-29 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -28,7 +28,6 @@ extra_rdoc_files:
28
28
  - README.rdoc
29
29
  files:
30
30
  - .gitignore
31
- - ":test"
32
31
  - MIT-LICENSE
33
32
  - README.rdoc
34
33
  - Rakefile
data/:test DELETED
File without changes