role_authorization 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ class Role < ActiveRecord::Base
2
+ acts_as_role_manager
3
+
4
+ def to_s
5
+ nickname.to_s.humanize
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class AddRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles do |t|
4
+ t.string :name
5
+ t.string :nickname
6
+ t.text :user_ids
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module RoleAuthorization
2
- class Railtie < Rails::Railtie
2
+ class Railtie < Rails::Engine
3
3
  initializer "role_authorization.initialize" do |app|
4
4
  RoleAuthorization.load_rules
5
5
  ::ActiveRecord::Base.send :extend, RoleAuthorization::ActiveRecord if defined?(::ActiveRecord)
@@ -18,7 +18,7 @@ module RoleAuthorization
18
18
  add_role_authorization_filter
19
19
  end
20
20
 
21
- def allow(&block)
21
+ def allow(options = {}, &block)
22
22
  add_to_ruleset(self.controller_rule_name, &block)
23
23
  add_role_authorization_filter
24
24
  end
@@ -40,6 +40,7 @@ module RoleAuthorization
40
40
 
41
41
  module InstanceMethods
42
42
  def check_request_authorization
43
+ params[:role_authorization_user_data] = nil
43
44
  unless authorized_action?(self, self.class.controller_rule_name, action_name.to_sym, params[:id])
44
45
  raise SecurityError, "You do not have the required clearance to access this resource."
45
46
  end
@@ -18,7 +18,13 @@ module RoleAuthorization
18
18
  def authorized?(*args)
19
19
  @controller_instance, @controller, @action, @id = args
20
20
 
21
- instance_eval(&returning)
21
+ if instance_eval(&returning)
22
+ true
23
+ else
24
+ # need to run an on_fail proc?
25
+ controller_instance.instance_eval(&options[:on_fail]) if options[:on_fail]
26
+ false
27
+ end
22
28
  end
23
29
  end
24
30
  end
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.5.9"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-11 00:00:00.000000000Z
12
+ date: 2012-02-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &23450000 !ruby/object:Gem::Requirement
16
+ requirement: &19974160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *23450000
24
+ version_requirements: *19974160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &23449580 !ruby/object:Gem::Requirement
27
+ requirement: &19973740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *23449580
35
+ version_requirements: *19973740
36
36
  description: A gem for handling authorization in rails using roles
37
37
  email:
38
38
  - machinist@asceth.com
@@ -49,6 +49,8 @@ files:
49
49
  - LICENSE
50
50
  - README.md
51
51
  - Rakefile
52
+ - app/models/role.rb
53
+ - db/migrate/20120130200006_add_roles.rb
52
54
  - lib/rails/role_authorization.rb
53
55
  - lib/role_authorization.rb
54
56
  - lib/role_authorization/active_record.rb
@@ -88,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  version: '0'
89
91
  requirements: []
90
92
  rubyforge_project: role_authorization
91
- rubygems_version: 1.8.8
93
+ rubygems_version: 1.8.10
92
94
  signing_key:
93
95
  specification_version: 3
94
96
  summary: Role Authorization gem for Rails