lockdown 0.3.6 → 0.3.7
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.
@@ -3,81 +3,81 @@ require File.join(File.dirname(__FILE__), "session")
|
|
3
3
|
|
4
4
|
Lockdown::System.configure do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
#
|
64
|
-
|
65
|
-
#
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
data/lib/lockdown/system.rb
CHANGED
@@ -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
|
data/lib/lockdown/version.rb
CHANGED
@@ -4,7 +4,7 @@ module PermissionsHelper
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def permission_access_rights_value
|
7
|
-
|
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.
|
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-
|
12
|
+
date: 2008-05-01 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|