lockdown 1.3.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.5.0
@@ -15,6 +15,7 @@ module Lockdown
15
15
  module Lock
16
16
 
17
17
  def configure_lockdown
18
+ Lockdown.maybe_parse_init
18
19
  check_session_expiry
19
20
  store_location
20
21
  end
@@ -94,7 +95,7 @@ module Lockdown
94
95
 
95
96
  def ld_access_denied(e)
96
97
 
97
- RAILS_DEFAULT_LOGGER.info "Access denied: #{e}"
98
+ Lockdown.logger.info "Access denied: #{e}"
98
99
 
99
100
  if Lockdown::System.fetch(:logout_on_access_violation)
100
101
  reset_session
@@ -86,6 +86,9 @@ module Lockdown
86
86
  def set_user_group(name, *perms)
87
87
  user_groups[name] ||= []
88
88
  perms.each do |perm|
89
+ if permission_assigned_automatically?(perm)
90
+ raise Lockdown::InvalidPermissionAssignment, "Permission is assigned automatically. Please remove it from #{name} user group"
91
+ end
89
92
  user_groups[name].push(perm)
90
93
  end
91
94
  end
@@ -12,6 +12,12 @@ module Lockdown
12
12
  process_rules
13
13
 
14
14
  Lockdown::Database.sync_with_db unless skip_sync?
15
+
16
+ @initialized = true
17
+ end
18
+
19
+ def self.initialized?
20
+ @initialized
15
21
  end
16
22
 
17
23
  def self.fetch(key)
data/lib/lockdown.rb CHANGED
@@ -16,7 +16,7 @@ module Lockdown
16
16
  extend Lockdown::References
17
17
  extend Lockdown::Helper
18
18
 
19
- VERSION = '1.3.2'
19
+ VERSION = '1.4.0'
20
20
 
21
21
  class << self
22
22
  attr_accessor :logger
@@ -44,18 +44,22 @@ module Lockdown
44
44
  unless mixin_resource?("orms")
45
45
  raise NotImplementedError, "ORM unknown to Lockdown!"
46
46
  end
47
-
48
- if File.exists?(Lockdown.init_file)
49
- Lockdown.logger.info "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
50
- require Lockdown.init_file
51
- else
52
- Lockdown.logger.info "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
53
- end
54
47
  else
55
48
  Lockdown.logger.info "=> Note:: Lockdown cannot determine framework and therefore is not active.\n"
56
49
  end
57
50
  end # mixin
58
51
 
52
+ def maybe_parse_init
53
+ return if Lockdown::System.initialized?
54
+
55
+ if File.exists?(Lockdown.init_file)
56
+ Lockdown.logger.info "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
57
+ require Lockdown.init_file
58
+ else
59
+ Lockdown.logger.info "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
60
+ end
61
+ end
62
+
59
63
  private
60
64
 
61
65
  def mixin_resource?(str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-17 00:00:00 -04:00
12
+ date: 2009-11-06 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,6 @@ extra_rdoc_files:
32
32
  - README.txt
33
33
  files:
34
34
  - .gitignore
35
- - History.txt
36
35
  - README.txt
37
36
  - Rakefile
38
37
  - VERSION
@@ -51,7 +50,6 @@ files:
51
50
  - lib/lockdown/rules.rb
52
51
  - lib/lockdown/session.rb
53
52
  - lib/lockdown/system.rb
54
- - lockdown.gemspec
55
53
  - rails_generators/lockdown/lockdown_generator.rb
56
54
  - rails_generators/lockdown/templates/app/controllers/permissions_controller.rb
57
55
  - rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
data/History.txt DELETED
@@ -1,195 +0,0 @@
1
- == 0.7.1 2009-01-xx
2
- * Update init.rb with documentation on how to use admin namespaces
3
-
4
- == 0.7.0 2009-01-xx
5
- * Removed lockdown as an executable. Will always go through the generator used by the framework.
6
- * Removed references to classy inheritance. Directly coded some of classy inheritance's functionality into User model.
7
-
8
- == 0.6.3 2008-12-02
9
- * Fixed: Database sync was failing. Cause of refactor. Apologies
10
-
11
- == 0.6.2 2008-12-01
12
- * Fixed: Made call to action_methods instead of calculating controller actions
13
-
14
- == 0.6.1 2008-11-21
15
- * Fixed: Named routes were not being honored in link_to
16
-
17
- == 0.6.0 2008-11-15
18
- * Big refactor of internals
19
-
20
- == 0.5.22 2008-09-14
21
- * Update: Add test for future deprecation: Dependencies to be ActiveSupport::Dependencies
22
-
23
- == 0.5.21 2008-09-12
24
- * Updated lockdown to abide by config.active_record.timestamped_migrations introduced in Rails 2.1.1
25
- * Fixed: schlick fixed an issue with the user_groups edit.html.erb. thanks Michael!
26
-
27
- == 0.5.20 2008-08-04
28
- * Fixed authorized? method to avoid ActionController::Routing::Routes.recognize_path invalid return values
29
- * Added option[:session_timeout_method]. This method will be called when the session times out.
30
-
31
- == 0.5.19 2008-08-01
32
- * Modified the lockdown system to account for permissions added/removed from user groups in init.rb. This will NOT manage user groups defined via the admin screens.
33
- == 0.5.18 2008-07-23
34
- * Changed the generator options to simplify things. The default now is to generate all templates.
35
- == 0.5.17 2008-07-21
36
- * Updated included classy inheritance library 0.6.1.
37
- == 0.5.16 2008-07-18
38
- * Updated included classy inheritance library.
39
- == 0.5.14 2008-07-18
40
- * Change: option no_migration to skip-migrations to mimick other generator options
41
- * Fixed: errant creation of sessions directory in app/controllers
42
-
43
- == 0.5.13 2008-07-10
44
- * Add: Support for --namespace option on generator. Use as ./script generate lockdown --all --namespace=admin
45
-
46
- == 0.5.12 2008-07-02
47
- * Fix: Added production environment conditional to Dependencies.clear.
48
-
49
- == 0.5.11 2008-06-25
50
- * Update: Classy Inheritance to current version 0.4.4
51
-
52
- == 0.5.10 2008-06-24
53
- * Modified: Classy Inheritance is now bundled with Lockdown to simplify the user management screens.
54
- * Fixed: Templates: Use m.template with views to test for rails version for action_name issue
55
- * Added: Templates: Missing javascript for do_highlight
56
- * Fixed: Templates: Usage of ul for permissions and user groups.
57
- * Clean: Templates: Removed unnecessary :locals => {:f => f} attribute in _form partials
58
- * Clean: Templates: Changed text_field_tag to text_field.
59
-
60
- == 0.5.9 2008-06-19
61
- * Fixed: Added url.strip! to account for spaces. URI::split(url) was bombing if url contained spaces.
62
-
63
- == 0.5.8 2008-06-17
64
- * Fixed: External links are no longer restricted by link_to security.
65
- * Modified: Name of migration that adds admin user.
66
-
67
- == 0.5.7 2008-06-13
68
- * Fixed: Change password template, removed ajax usage. Issue: http://stonean.com/issues/show/5
69
-
70
- == 0.5.6 2008-06-05
71
- * Fixed: Misspelling of respond_to?, for some reason I keep thinking responds_to?
72
-
73
- == 0.5.5 2008-06-05
74
- * Fixed: Changed request comparison code. Requests that were supposed to be passing were failing.
75
-
76
- == 0.5.4 2008-06-05
77
- * Fixed: Issue with helpers in Rails 2.1, @action_name is no longer accessible, must call action_name method.
78
- * Fixed: Issue with users controller, show method not having user_groups_for_user instance variable
79
- * Modified: The end of the lockdown executable now references stonean.com instead of rubyforge site.
80
-
81
- == 0.5.3 2008-06-01
82
- * Fixed: Issue with new timestamped based migrations in rails 2.1. Migration templates created were all done within the same second, therefore having the same timestamp, added a sleep call to the next_migration_string to get around the issue.
83
-
84
- * Fixed: User Groups management template had a bug on the show screen. Was not getting @all_permissions instance variable set.
85
-
86
- == 0.5.2 2008-05-26
87
- * Fixed: make call to Dependencies.clear after inspecting controllers. Using Dependencies.require_or_load is not sufficient it seems.
88
-
89
- == 0.5.1 2008-05-25
90
- * Fixed: bug with namespaced access having identical standard access. e.g. /users and /admin/users
91
-
92
- == 0.5.0 2008-05-22
93
- * Added: new generator options for more control over templates
94
- * Fixed: sessions_controller successful_login didn't honor Lockdown::System options setting for :successful_login_path
95
- * Modified: System had [] method which could cause issues in future releases. Use Lockdown::System.fetch(:option) to retrieve options
96
-
97
- == 0.4.6 2008-05-08
98
- * Fixed: link_to destroy/show conditionals were in wrong order and therefore not working.
99
-
100
- == 0.4.5 2008-05-08
101
- * Rubyforge having an issue with the gem, I'm getting 404 errors trying to install 0.4.4 so I'm deploying a new version. no code changes.
102
-
103
- == 0.4.4 2008-05-08
104
- * Modified: refactored the link_to_secured and authorized? code to be more efficient
105
-
106
- == 0.4.3 2008-05-08
107
- * Fixed: broken show (and destroy) permission test. also reduced calls to polymorphic path by generating the url once
108
-
109
- == 0.4.2 2008-05-08
110
- * Fixed: broken link_to functionality.
111
-
112
- == 0.4.1 2008-05-06
113
- * Just some minor tabs-to-spaces formatting and removed unnecessary helper included into the user model.
114
-
115
- == 0.4.0 2008-05-04
116
- * Added: Automatically sync definitions in init.rb with database to remove migrations requirement
117
- * Added: Improved notification if invalid user group or permission is referenced in init.rb
118
- * Added: Check in user_groups controller to prevent url hack and modify/destroy user group defined in init.rb
119
- * Modified: Renamed access_rights_for_perm to access_rights_for_permission for consistency sake. Change then method call in permissions_helper if you have this installed
120
-
121
- == 0.3.15 2008-05-03
122
- * Fixed: The controller inspection code was short-circuiting the Dependencies reload mechanism while in development mode.
123
-
124
- == 0.3.14 2008-05-02
125
- * Fixed: Session keys to use symbols. Wasn't correctly expiring the session.
126
-
127
- == 0.3.13 2008-05-02
128
- * Fixed: The users and user_groups controller templates needed user_groups_for_users and all_permissions (respectively) instance variables set if validation failed on update.
129
-
130
- == 0.3.12 2008-05-02
131
- * Fixed: The timestamps were being set on created_by and updated_by.
132
- * Changed: The init.rb and lockdown_all interaction to better define where configurations should be placed.
133
-
134
- == 0.3.11 2008-05-01
135
- * Modified: Lockdown::System controller inspect to use "load" instead of "require".
136
-
137
- == 0.3.10 2008-05-01
138
- * Fixed: users_controller management of user_groups was using outdated methods. this applies only to the stubs produced with the generator
139
-
140
- == 0.3.9 2008-05-01
141
- * Modify: changed controller_classes from array to hash to speed up access
142
-
143
- == 0.3.8 2008-05-01
144
- * Fixed: corrected class loader to ensure ObjectSpace is used only once
145
-
146
- == 0.3.7 2008-05-01
147
- * Fixed: access rights list for permissions. maded modifications to permissions helper as well.
148
-
149
- == 0.3.6 2008-04-30
150
- * Fixed: The block in init.rb does not take a parameter. This has been removed from the template.
151
-
152
- == 0.3.5 2008-04-30
153
- * Added: Basic configuations to config/lockdown/init.rb when using the generator
154
-
155
- == 0.3.4 2008-04-30
156
- * Fixed: Addition of require 'lockdown/init' to config file
157
-
158
- == 0.3.3 2008-04-30
159
- * Spoke too soon. Omitted user_group controller change.
160
-
161
- == 0.3.2 2008-04-30
162
- * Management screens looking good. Now moving on to testing with starter application.
163
-
164
- == 0.3.1 2008-04-29
165
- * Some initital testing done.
166
-
167
- == 0.3.0 2008-04-29
168
- * Big change in how the system is installed and configured in the project.
169
- Introduced lib/lockdown/init.rb.
170
- Removed lib/lockdown/access.rb.
171
- Now use more of a Rails-ish initializer functionality. This adds flexibility
172
- and places the core code back in the gem, that's what I was after.
173
-
174
- == 0.2.0 2008-04-25
175
- * First full implementation of generate script "lockdown_all". Warranted a bump up of the minor version.
176
-
177
- == 0.1.4 2008-04-25
178
- * Uncommented line in config/hoe.rb to hopefully resolved rubigen dependency issue.
179
-
180
- == 0.1.3 2008-04-25
181
- * Still Don't have correct dependencies. Added in first crack at lockdown_all generator.
182
-
183
- == 0.1.2 2008-04-25
184
- * Didn't have correct dependencies.
185
-
186
- == 0.1.1 2008-04-24
187
- * Fixed bug with session cleanup.
188
-
189
- == 0.1.0 2008-04-18
190
- * Nearing public release status.
191
- * In bug testing mode now.
192
-
193
- == 0.0.1 2008-04-18
194
-
195
- * initial add of gem
data/lockdown.gemspec DELETED
@@ -1,119 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{lockdown}
8
- s.version = "1.3.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andrew Stone"]
12
- s.date = %q{2009-10-17}
13
- s.description = %q{Restrict access to your controller actions. Supports basic model level restrictions as well}
14
- s.email = %q{andy@stonean.com}
15
- s.extra_rdoc_files = [
16
- "README.txt"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "History.txt",
21
- "README.txt",
22
- "Rakefile",
23
- "VERSION",
24
- "lib/lockdown.rb",
25
- "lib/lockdown/context.rb",
26
- "lib/lockdown/database.rb",
27
- "lib/lockdown/errors.rb",
28
- "lib/lockdown/frameworks/rails.rb",
29
- "lib/lockdown/frameworks/rails/controller.rb",
30
- "lib/lockdown/frameworks/rails/view.rb",
31
- "lib/lockdown/helper.rb",
32
- "lib/lockdown/orms/active_record.rb",
33
- "lib/lockdown/permission.rb",
34
- "lib/lockdown/references.rb",
35
- "lib/lockdown/rspec_helper.rb",
36
- "lib/lockdown/rules.rb",
37
- "lib/lockdown/session.rb",
38
- "lib/lockdown/system.rb",
39
- "lockdown.gemspec",
40
- "rails_generators/lockdown/lockdown_generator.rb",
41
- "rails_generators/lockdown/templates/app/controllers/permissions_controller.rb",
42
- "rails_generators/lockdown/templates/app/controllers/sessions_controller.rb",
43
- "rails_generators/lockdown/templates/app/controllers/user_groups_controller.rb",
44
- "rails_generators/lockdown/templates/app/controllers/users_controller.rb",
45
- "rails_generators/lockdown/templates/app/helpers/permissions_helper.rb",
46
- "rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb",
47
- "rails_generators/lockdown/templates/app/helpers/users_helper.rb",
48
- "rails_generators/lockdown/templates/app/models/permission.rb",
49
- "rails_generators/lockdown/templates/app/models/profile.rb",
50
- "rails_generators/lockdown/templates/app/models/user.rb",
51
- "rails_generators/lockdown/templates/app/models/user_group.rb",
52
- "rails_generators/lockdown/templates/app/views/permissions/index.html.erb",
53
- "rails_generators/lockdown/templates/app/views/permissions/show.html.erb",
54
- "rails_generators/lockdown/templates/app/views/sessions/new.html.erb",
55
- "rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb",
56
- "rails_generators/lockdown/templates/app/views/user_groups/index.html.erb",
57
- "rails_generators/lockdown/templates/app/views/user_groups/new.html.erb",
58
- "rails_generators/lockdown/templates/app/views/user_groups/show.html.erb",
59
- "rails_generators/lockdown/templates/app/views/users/edit.html.erb",
60
- "rails_generators/lockdown/templates/app/views/users/index.html.erb",
61
- "rails_generators/lockdown/templates/app/views/users/new.html.erb",
62
- "rails_generators/lockdown/templates/app/views/users/show.html.erb",
63
- "rails_generators/lockdown/templates/config/initializers/lockit.rb",
64
- "rails_generators/lockdown/templates/db/migrate/create_admin_user.rb",
65
- "rails_generators/lockdown/templates/db/migrate/create_permissions.rb",
66
- "rails_generators/lockdown/templates/db/migrate/create_profiles.rb",
67
- "rails_generators/lockdown/templates/db/migrate/create_user_groups.rb",
68
- "rails_generators/lockdown/templates/db/migrate/create_users.rb",
69
- "rails_generators/lockdown/templates/lib/lockdown/README",
70
- "rails_generators/lockdown/templates/lib/lockdown/init.rb",
71
- "spec/lockdown/context_spec.rb",
72
- "spec/lockdown/database_spec.rb",
73
- "spec/lockdown/frameworks/rails/controller_spec.rb",
74
- "spec/lockdown/frameworks/rails/view_spec.rb",
75
- "spec/lockdown/frameworks/rails_spec.rb",
76
- "spec/lockdown/permission_spec.rb",
77
- "spec/lockdown/rspec_helper_spec.rb",
78
- "spec/lockdown/rules_spec.rb",
79
- "spec/lockdown/session_spec.rb",
80
- "spec/lockdown/system_spec.rb",
81
- "spec/lockdown_spec.rb",
82
- "spec/rcov.opts",
83
- "spec/spec.opts",
84
- "spec/spec_helper.rb"
85
- ]
86
- s.homepage = %q{http://stonean.com/wiki/lockdown}
87
- s.rdoc_options = ["--charset=UTF-8"]
88
- s.require_paths = ["lib"]
89
- s.rubyforge_project = %q{lockdown}
90
- s.rubygems_version = %q{1.3.5}
91
- s.summary = %q{Authorization system for Rails 2.x}
92
- s.test_files = [
93
- "spec/lockdown/context_spec.rb",
94
- "spec/lockdown/database_spec.rb",
95
- "spec/lockdown/frameworks/rails/controller_spec.rb",
96
- "spec/lockdown/frameworks/rails/view_spec.rb",
97
- "spec/lockdown/frameworks/rails_spec.rb",
98
- "spec/lockdown/permission_spec.rb",
99
- "spec/lockdown/rspec_helper_spec.rb",
100
- "spec/lockdown/rules_spec.rb",
101
- "spec/lockdown/session_spec.rb",
102
- "spec/lockdown/system_spec.rb",
103
- "spec/lockdown_spec.rb",
104
- "spec/spec_helper.rb"
105
- ]
106
-
107
- if s.respond_to? :specification_version then
108
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
109
- s.specification_version = 3
110
-
111
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
112
- s.add_development_dependency(%q<rspec>, [">= 0"])
113
- else
114
- s.add_dependency(%q<rspec>, [">= 0"])
115
- end
116
- else
117
- s.add_dependency(%q<rspec>, [">= 0"])
118
- end
119
- end