lockdown 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,81 +3,81 @@ require File.join(File.dirname(__FILE__), "session")
3
3
 
4
4
  Lockdown::System.configure do
5
5
 
6
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
- # Configuration Options
8
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
- # Options with defaults:
10
- #
11
- # Set timeout to 1 hour:
12
- # options[:session_timeout] = (60 * 60)
13
- #
14
- # Set system to logout if unauthorized access is attempted:
15
- # options[:logout_on_access_violation] = false
16
- #
17
- # Set redirect to path on unauthorized access attempt:
18
- # options[:access_denied_path] = "/"
19
- #
20
- # Set redirect to path on successful login:
21
- # options[:successful_login_path] = "/"
22
- #
23
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
- # Define permissions
25
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
- #
27
- # set_permission(:product_management, all_methods(:products))
28
- #
29
- # :product_management is the name of the permission which is later
30
- # referenced by the user_group method
31
- #
32
- # :all_methods(:products) will return an array of all controller actions
33
- # for the products controller
34
- #
35
- # if products is your standard RESTful resource you'll get:
36
- # ["products/index , "products/show",
37
- # "products/new", "products/edit",
38
- # "products/create", "products/update",
39
- # "products/destroy"]
40
- #
41
- # You can pass multiple parameters to concat permissions such as:
42
- #
43
- # set_permission(:security_management,all_methods(:users),
44
- # all_methods(:user_groups),
45
- # all_methods(:permissions) )
46
- #
47
- # In addition to all_methods(:controller) there are:
48
- #
49
- # only_methods(:controller, :only_method_1, :only_method_2)
50
- #
51
- # all_except_methods(:controller, :except_method_1, :except_method_2)
52
- #
53
- # Some other sample permissions:
54
- #
55
- # set_permission(:sessions, all_methods(:sessions))
56
- # set_permission(:my_account, only_methods(:users, :edit, :update, :show))
57
- #
58
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
- # Built-in user groups
60
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
- # You can assign the above permission to one of the built-in user groups
62
- # by using the following:
63
- #
64
- # To allow public access on the permissions :sessions and :home:
65
- # set_public_access :sessions, :home
66
- #
67
- #
68
- # Restrict :my_account access to only authenticated users:
69
- # set_protected_access :my_account
70
- #
71
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
- # Define user groups
73
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
- #
75
- # set_user_group(:catalog_management, :category_management,
76
- # :product_management)
77
- #
78
- # :catalog_management is the name of the user group
79
- # :category_management and :product_management refer to permission names
80
- #
81
-
82
- # Add your configuration below:
6
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
+ # Configuration Options
8
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
+ # Options with defaults:
10
+ #
11
+ # Set timeout to 1 hour:
12
+ # options[:session_timeout] = (60 * 60)
13
+ #
14
+ # Set system to logout if unauthorized access is attempted:
15
+ # options[:logout_on_access_violation] = false
16
+ #
17
+ # Set redirect to path on unauthorized access attempt:
18
+ # options[:access_denied_path] = "/"
19
+ #
20
+ # Set redirect to path on successful login:
21
+ # options[:successful_login_path] = "/"
22
+ #
23
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
+ # Define permissions
25
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
+ #
27
+ # set_permission(:product_management, all_methods(:products))
28
+ #
29
+ # :product_management is the name of the permission which is later
30
+ # referenced by the set_user_group method
31
+ #
32
+ # :all_methods(:products) will return an array of all controller actions
33
+ # for the products controller
34
+ #
35
+ # if products is your standard RESTful resource you'll get:
36
+ # ["products/index , "products/show",
37
+ # "products/new", "products/edit",
38
+ # "products/create", "products/update",
39
+ # "products/destroy"]
40
+ #
41
+ # You can pass multiple parameters to concat permissions such as:
42
+ #
43
+ # set_permission(:security_management,all_methods(:users),
44
+ # all_methods(:user_groups),
45
+ # all_methods(:permissions) )
46
+ #
47
+ # In addition to all_methods(:controller) there are:
48
+ #
49
+ # only_methods(:controller, :only_method_1, :only_method_2)
50
+ #
51
+ # all_except_methods(:controller, :except_method_1, :except_method_2)
52
+ #
53
+ # Some other sample permissions:
54
+ #
55
+ # set_permission(:sessions, all_methods(:sessions))
56
+ # set_permission(:my_account, only_methods(:users, :edit, :update, :show))
57
+ #
58
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
+ # Built-in user groups
60
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
+ # You can assign the above permission to one of the built-in user groups
62
+ # by using the following:
63
+ #
64
+ # To allow public access on the permissions :sessions and :home:
65
+ # set_public_access :sessions, :home
66
+ #
67
+ # Restrict :my_account access to only authenticated users:
68
+ # set_protected_access :my_account
69
+ #
70
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71
+ # Define user groups
72
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73
+ #
74
+ # set_user_group(:catalog_management, :category_management,
75
+ # :product_management)
76
+ #
77
+ # :catalog_management is the name of the user group
78
+ # :category_management and :product_management refer to permission names
79
+ #
80
+
81
+ # Add your configuration below:
82
+
83
83
  end
@@ -125,6 +125,10 @@ module Lockdown
125
125
  rights
126
126
  end
127
127
 
128
+ def access_rights_for_perm(perm)
129
+ (perms = @permissions[symbol_name(perm.name)]) == nil ? [] : perms
130
+ end
131
+
128
132
  #
129
133
  # Use this for the management screen to restrict user group list to the
130
134
  # user. This will prevent a user from creating a user with more power than
@@ -2,7 +2,7 @@ module Lockdown #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -4,7 +4,7 @@ module PermissionsHelper
4
4
  end
5
5
 
6
6
  def permission_access_rights_value
7
- @permission.access_rights.collect{|r| r}.join("<br/>") if @permission.access_rights
7
+ Lockdown::System.access_rights_for_perm(@permission).collect{|r| r}.join("<br/>")
8
8
  end
9
9
 
10
10
  def permission_users_value
data/website/index.txt CHANGED
@@ -136,24 +136,6 @@ Lockdown::System.configure do
136
136
  end
137
137
  </pre>
138
138
 
139
-
140
-
141
- h2. Some History
142
-
143
- Lockdown was initially designed as a authentication/authorization system to be configured by system administrators. This means it was database driven and had an interface to manage the access rights. I didn't like the static methodology of using code scattered amongst the controllers to define my access rights for the system. I also didn't like the fact that everything was accessible unless you restricted access. So, I designed Lockdown to restrict access to all resources unless rights have been granted.
144
-
145
- The system was nice and worked well until I had a project that required RSpec tests. I don't have anything against testing frameworks (now that I've see the light) but what bothered me most what the fact that I would have to duplicate the information I already defined in my migrations as mock data. I simply refused to do that extra work. So, a serious refactoring of Lockdown was required.
146
-
147
-
148
- After the RSpec project was completed, the refactoring continued. This time the focus was on releasing the code to the masses. I like this system a lot and think both the system itself and the community could benefit from releasing this as an open source project.
149
-
150
- In the middle of my refactoring for a public release, I made the decision to use Merb (when the choice was mine). This meant I needed to modify Lockdown for use with Merb. So this is what I have done.
151
-
152
- There is code in place for using Lockdown with Rails, after all, that's where Lockdown was born. However, I have not yet tested the Rails functionality after this last refactor. In addition, the deployment mechanism for Rails has to be tested.
153
-
154
- Writing code for public release is difficult and much different from architecting/coding for a closed source project. A lot of things you could get by with in a proprietary application won't be well received by the general public. In addition, if you don't make things easy, the adoption rate will probably be non-existent.
155
-
156
-
157
139
  h2. Forum
158
140
 
159
141
  If you are having a problem understanding how to use Lockdown, please post your question on the lockdown group. If it's documentation related, I will keep this page updated to help everyone.
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: 0.3.6
4
+ version: 0.3.7
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: 2008-04-30 00:00:00 -04:00
12
+ date: 2008-05-01 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency