cbac 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,6 +1,7 @@
1
1
  Manifest
2
2
  README.rdoc
3
3
  Rakefile
4
+ cbac.gemspec
4
5
  generators/cbac/USAGE
5
6
  generators/cbac/cbac_generator.rb
6
7
  generators/cbac/templates/config/cbac.pristine
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
24
24
  rdoc.rdoc_files.include('lib/**/*.rb')
25
25
  end
26
26
 
27
- Echoe.new('cbac', '0.5.2') do |p|
27
+ Echoe.new('cbac', '0.5.3') do |p|
28
28
  p.summary = "CBAC - Simple authorization system for Rails applications."
29
29
  p.description = "Simple authorization system for Rails applications. Allows you to develop applications with a mixed role based authorization and a context based authorization model. Does not supply authentication."
30
30
  p.url = "http://cbac.rubyforge.org"
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cbac}
5
- s.version = "0.5.2"
5
+ s.version = "0.5.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bert Meerman"]
9
- s.date = %q{2010-10-27}
9
+ s.date = %q{2010-11-18}
10
10
  s.description = %q{Simple authorization system for Rails applications. Allows you to develop applications with a mixed role based authorization and a context based authorization model. Does not supply authentication.}
11
11
  s.email = %q{bertm@rubyforge.org}
12
12
  s.extra_rdoc_files = ["README.rdoc", "lib/cbac.rb", "lib/cbac/cbac_pristine/pristine.rb", "lib/cbac/cbac_pristine/pristine_file.rb", "lib/cbac/cbac_pristine/pristine_permission.rb", "lib/cbac/cbac_pristine/pristine_role.rb", "lib/cbac/config.rb", "lib/cbac/context_role.rb", "lib/cbac/generic_role.rb", "lib/cbac/known_permission.rb", "lib/cbac/membership.rb", "lib/cbac/permission.rb", "lib/cbac/privilege.rb", "lib/cbac/privilege_set.rb", "lib/cbac/privilege_set_record.rb", "lib/cbac/setup.rb", "tasks/cbac.rake"]
13
- s.files = ["README.rdoc", "Rakefile", "generators/cbac/USAGE", "generators/cbac/cbac_generator.rb", "generators/cbac/templates/config/cbac.pristine", "generators/cbac/templates/config/context_roles.rb", "generators/cbac/templates/config/privileges.rb", "generators/cbac/templates/controllers/generic_roles_controller.rb", "generators/cbac/templates/controllers/memberships_controller.rb", "generators/cbac/templates/controllers/permissions_controller.rb", "generators/cbac/templates/controllers/upgrade_controller.rb", "generators/cbac/templates/fixtures/cbac_generic_roles.yml", "generators/cbac/templates/fixtures/cbac_memberships.yml", "generators/cbac/templates/fixtures/cbac_permissions.yml", "generators/cbac/templates/migrate/create_cbac_from_scratch.rb", "generators/cbac/templates/migrate/create_cbac_upgrade_path.rb", "generators/cbac/templates/stylesheets/cbac.css", "generators/cbac/templates/tasks/cbac.rake", "generators/cbac/templates/views/generic_roles/index.html.erb", "generators/cbac/templates/views/layouts/cbac.html.erb", "generators/cbac/templates/views/memberships/_update.html.erb", "generators/cbac/templates/views/memberships/index.html.erb", "generators/cbac/templates/views/permissions/_update_context_role.html.erb", "generators/cbac/templates/views/permissions/_update_generic_role.html.erb", "generators/cbac/templates/views/permissions/index.html.erb", "generators/cbac/templates/views/upgrade/index.html.erb", "init.rb", "lib/cbac.rb", "lib/cbac/cbac_pristine/pristine.rb", "lib/cbac/cbac_pristine/pristine_file.rb", "lib/cbac/cbac_pristine/pristine_permission.rb", "lib/cbac/cbac_pristine/pristine_role.rb", "lib/cbac/config.rb", "lib/cbac/context_role.rb", "lib/cbac/generic_role.rb", "lib/cbac/known_permission.rb", "lib/cbac/membership.rb", "lib/cbac/permission.rb", "lib/cbac/privilege.rb", "lib/cbac/privilege_set.rb", "lib/cbac/privilege_set_record.rb", "lib/cbac/setup.rb", "spec/cbac_pristine_file_spec.rb", "spec/cbac_pristine_permission_spec.rb", "spec/cbac_pristine_role_spec.rb", "spec/rcov.opts", "spec/spec.opts", "spec/spec_helper.rb", "tasks/cbac.rake", "test/fixtures/cbac_generic_roles.yml", "test/fixtures/cbac_memberships.yml", "test/fixtures/cbac_permissions.yml", "test/fixtures/cbac_privilege_set.yml", "test/test_cbac_authorize_context_roles.rb", "test/test_cbac_authorize_generic_roles.rb", "test/test_cbac_context_role.rb", "test/test_cbac_privilege.rb", "test/test_cbac_privilege_set.rb", "Manifest", "cbac.gemspec"]
13
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "cbac.gemspec", "generators/cbac/USAGE", "generators/cbac/cbac_generator.rb", "generators/cbac/templates/config/cbac.pristine", "generators/cbac/templates/config/context_roles.rb", "generators/cbac/templates/config/privileges.rb", "generators/cbac/templates/controllers/generic_roles_controller.rb", "generators/cbac/templates/controllers/memberships_controller.rb", "generators/cbac/templates/controllers/permissions_controller.rb", "generators/cbac/templates/controllers/upgrade_controller.rb", "generators/cbac/templates/fixtures/cbac_generic_roles.yml", "generators/cbac/templates/fixtures/cbac_memberships.yml", "generators/cbac/templates/fixtures/cbac_permissions.yml", "generators/cbac/templates/migrate/create_cbac_from_scratch.rb", "generators/cbac/templates/migrate/create_cbac_upgrade_path.rb", "generators/cbac/templates/stylesheets/cbac.css", "generators/cbac/templates/tasks/cbac.rake", "generators/cbac/templates/views/generic_roles/index.html.erb", "generators/cbac/templates/views/layouts/cbac.html.erb", "generators/cbac/templates/views/memberships/_update.html.erb", "generators/cbac/templates/views/memberships/index.html.erb", "generators/cbac/templates/views/permissions/_update_context_role.html.erb", "generators/cbac/templates/views/permissions/_update_generic_role.html.erb", "generators/cbac/templates/views/permissions/index.html.erb", "generators/cbac/templates/views/upgrade/index.html.erb", "init.rb", "lib/cbac.rb", "lib/cbac/cbac_pristine/pristine.rb", "lib/cbac/cbac_pristine/pristine_file.rb", "lib/cbac/cbac_pristine/pristine_permission.rb", "lib/cbac/cbac_pristine/pristine_role.rb", "lib/cbac/config.rb", "lib/cbac/context_role.rb", "lib/cbac/generic_role.rb", "lib/cbac/known_permission.rb", "lib/cbac/membership.rb", "lib/cbac/permission.rb", "lib/cbac/privilege.rb", "lib/cbac/privilege_set.rb", "lib/cbac/privilege_set_record.rb", "lib/cbac/setup.rb", "spec/cbac_pristine_file_spec.rb", "spec/cbac_pristine_permission_spec.rb", "spec/cbac_pristine_role_spec.rb", "spec/rcov.opts", "spec/spec.opts", "spec/spec_helper.rb", "tasks/cbac.rake", "test/fixtures/cbac_generic_roles.yml", "test/fixtures/cbac_memberships.yml", "test/fixtures/cbac_permissions.yml", "test/fixtures/cbac_privilege_set.yml", "test/test_cbac_authorize_context_roles.rb", "test/test_cbac_authorize_generic_roles.rb", "test/test_cbac_context_role.rb", "test/test_cbac_privilege.rb", "test/test_cbac_privilege_set.rb"]
14
14
  s.homepage = %q{http://cbac.rubyforge.org}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cbac", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
@@ -9,6 +9,7 @@ module Cbac
9
9
  def initialize(file_name)
10
10
  @file_name = file_name
11
11
  @generic_roles = []
12
+ @context_roles = []
12
13
  @permissions = []
13
14
  @admin_role = nil
14
15
  end
@@ -126,8 +127,18 @@ module Cbac
126
127
  if context_role_name = line.match(/^.*ContextRole\(\s*([A-Za-z0-9_]+)\s*\)/)
127
128
  # NOTE: the 0 for an ID is very important! In CBAC a context role permission MUST have 0 as generic_role_id
128
129
  # if not, the context role is not found by CBAC and thus will not work
130
+
131
+ # this may be a context role that's already in the database
129
132
  context_role = use_db ? PristineRole.first(:conditions => {:role_type => PristineRole.ROLE_TYPES[:context], :name => context_role_name.captures[0]}) : nil
130
- context_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:context], :name => context_role_name.captures[0]) if context_role.nil?
133
+
134
+ # this may still be a context role we've seen before...
135
+ context_role = @context_roles.select do |cr| cr.role_type == PristineRole.ROLE_TYPES[:context] and cr.name == context_role_name.captures[0] end.first if context_role.nil?
136
+
137
+ if context_role.nil?
138
+ # this is a never-before-seen context role
139
+ context_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:context], :name => context_role_name.captures[0]) if context_role.nil?
140
+ @context_roles.push context_role
141
+ end
131
142
  return context_role
132
143
  end
133
144
  raise SyntaxError, "Error: ContextRole or Admin expected, but found: \"#{line}\" on line #{(line_number + 1).to_s}"
@@ -1,8 +1,9 @@
1
1
  require 'spec'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
3
+ require 'cbac/cbac_pristine/pristine'
2
4
  require 'cbac/cbac_pristine/pristine_permission'
3
5
  require 'cbac/cbac_pristine/pristine_role'
4
6
  require 'cbac/cbac_pristine/pristine_file'
5
- require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
6
7
  include Cbac::CbacPristine
7
8
 
8
9
  describe "CbacPristineFile" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbac
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bert Meerman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-27 00:00:00 +02:00
18
+ date: 2010-11-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -44,8 +44,10 @@ extra_rdoc_files:
44
44
  - lib/cbac/setup.rb
45
45
  - tasks/cbac.rake
46
46
  files:
47
+ - Manifest
47
48
  - README.rdoc
48
49
  - Rakefile
50
+ - cbac.gemspec
49
51
  - generators/cbac/USAGE
50
52
  - generators/cbac/cbac_generator.rb
51
53
  - generators/cbac/templates/config/cbac.pristine
@@ -102,8 +104,6 @@ files:
102
104
  - test/test_cbac_context_role.rb
103
105
  - test/test_cbac_privilege.rb
104
106
  - test/test_cbac_privilege_set.rb
105
- - Manifest
106
- - cbac.gemspec
107
107
  has_rdoc: true
108
108
  homepage: http://cbac.rubyforge.org
109
109
  licenses: []