lockdown 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/app_generators/lockdown/templates/init.rb +6 -2
- data/lib/lockdown/model.rb +4 -4
- data/lib/lockdown/version.rb +1 -1
- data/lib/lockdown.rb +1 -1
- data/rails_generators/lockdown_all/lockdown_all_generator.rb +13 -5
- data/website/index.txt +59 -11
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 0.3.12 2008-05-02
|
2
|
+
* Fixed: The timestamps were being set on created_by and updated_by.
|
3
|
+
* Changed: The init.rb and lockdown_all interaction to better define where configurations should be placed.
|
4
|
+
|
1
5
|
== 0.3.11 2008-05-01
|
2
6
|
* Modified: Lockdown::System controller inspect to use "load" instead of "require".
|
3
7
|
|
@@ -55,6 +55,8 @@ Lockdown::System.configure do
|
|
55
55
|
# set_permission(:sessions, all_methods(:sessions))
|
56
56
|
# set_permission(:my_account, only_methods(:users, :edit, :update, :show))
|
57
57
|
#
|
58
|
+
# Define your permissions here:
|
59
|
+
|
58
60
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
59
61
|
# Built-in user groups
|
60
62
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -67,6 +69,8 @@ Lockdown::System.configure do
|
|
67
69
|
# Restrict :my_account access to only authenticated users:
|
68
70
|
# set_protected_access :my_account
|
69
71
|
#
|
72
|
+
# Define the built-in user groups here:
|
73
|
+
|
70
74
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
71
75
|
# Define user groups
|
72
76
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -77,7 +81,7 @@ Lockdown::System.configure do
|
|
77
81
|
# :catalog_management is the name of the user group
|
78
82
|
# :category_management and :product_management refer to permission names
|
79
83
|
#
|
80
|
-
|
81
|
-
#
|
84
|
+
#
|
85
|
+
# Define your user groups here:
|
82
86
|
|
83
87
|
end
|
data/lib/lockdown/model.rb
CHANGED
@@ -7,8 +7,10 @@ module Lockdown
|
|
7
7
|
module InstanceMethods
|
8
8
|
def self.included(base)
|
9
9
|
base.class_eval do
|
10
|
-
|
11
|
-
|
10
|
+
alias_method :create_without_stamps, :create
|
11
|
+
alias_method :create, :create_with_stamps
|
12
|
+
alias_method :update_without_stamps, :update
|
13
|
+
alias_method :update, :update_with_stamps
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
@@ -23,14 +25,12 @@ module Lockdown
|
|
23
25
|
self[:updated_by] = profile_id if self.respond_to?(:updated_by)
|
24
26
|
create_without_stamps
|
25
27
|
end
|
26
|
-
alias :create :create_with_stamps
|
27
28
|
|
28
29
|
def update_with_stamps
|
29
30
|
profile_id = current_profile_id || Profile::SYSTEM
|
30
31
|
self[:updated_by] = profile_id if self.respond_to?(:updated_by)
|
31
32
|
update_without_stamps
|
32
33
|
end
|
33
|
-
alias :update :update_with_stamps
|
34
34
|
end # InstanceMethods
|
35
35
|
end # Model
|
36
36
|
end # Lockdown
|
data/lib/lockdown/version.rb
CHANGED
data/lib/lockdown.rb
CHANGED
@@ -72,7 +72,7 @@ module Lockdown
|
|
72
72
|
include Lockdown::Helper
|
73
73
|
|
74
74
|
def nil_lockdown_values
|
75
|
-
%w(user_id user_name user_profile_id access_rights).each do |val|
|
75
|
+
%w(expiry_time user_id user_name user_profile_id access_rights).each do |val|
|
76
76
|
session[val] = nil if session[val]
|
77
77
|
end
|
78
78
|
end
|
@@ -157,7 +157,7 @@ EOS
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def add_permissions(m)
|
160
|
-
|
160
|
+
perms = <<-PERMS
|
161
161
|
|
162
162
|
set_permission :sessions_management, all_methods(:sessions)
|
163
163
|
|
@@ -169,16 +169,24 @@ EOS
|
|
169
169
|
|
170
170
|
set_permission :my_account, only_methods(:users, :edit, :update, :show)
|
171
171
|
|
172
|
+
PERMS
|
172
173
|
|
174
|
+
sentinel = '# Define your permissions here:'
|
175
|
+
m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
176
|
+
"#{match}\n#{perms}"
|
177
|
+
end
|
178
|
+
|
179
|
+
predefined_user_groups = <<-PUG
|
173
180
|
set_public_access :sessions_management
|
174
181
|
|
175
182
|
set_protected_access :my_account
|
176
|
-
|
177
|
-
|
178
|
-
sentinel = '# Add your configuration below:'
|
183
|
+
PUG
|
179
184
|
|
185
|
+
sentinel = '# Define the built-in user groups here:'
|
180
186
|
m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
181
|
-
"#{match}\n#{
|
187
|
+
"#{match}\n#{predefined_user_groups}"
|
182
188
|
end
|
189
|
+
|
190
|
+
|
183
191
|
end
|
184
192
|
end
|
data/website/index.txt
CHANGED
@@ -1,18 +1,10 @@
|
|
1
|
-
h1. lockdown
|
2
|
-
|
3
|
-
h1. → 'lockdown'
|
1
|
+
h1. <a href="http://lockdown.rubyforge.org">Lockdown</a>
|
4
2
|
|
5
3
|
h3. Lockdown has not been officially released! This page is a Work-In-Progress.
|
6
4
|
|
7
5
|
h2. What
|
8
6
|
|
9
|
-
Lockdown is a authentication/authorization system for RubyOnRails
|
10
|
-
|
11
|
-
If there is a "spec" directory, a test helper file will be included to provied some basic functionality for use with RSpec. This will show you how to create mock user objects and sign in as an adminstrator.
|
12
|
-
|
13
|
-
Also included is functionality to auto-populate created_by and updated_by fields.
|
14
|
-
|
15
|
-
Some model level access right functionality will also be added in the near future.
|
7
|
+
Lockdown is a authentication/authorization system for RubyOnRails (ver 2.x). While Merb functionality is in place, it is not complete. There will be a release solely focused on getting the Merb functionality up to par with Rails.
|
16
8
|
|
17
9
|
h2. Installing
|
18
10
|
|
@@ -26,13 +18,25 @@ $ lockdown .
|
|
26
18
|
|
27
19
|
This will create a "lockdown" directory in the lib dir add two files: init.rb and session.rb. Modify init.rb to set defaults and define the rules that apply to your system.
|
28
20
|
|
29
|
-
|
21
|
+
To help you with your new application, Lockdown comes with a generator called lockdown_all.
|
30
22
|
|
31
23
|
<pre>
|
32
24
|
$ cd <your_project_directory>
|
33
25
|
$ ./script/generate lockdown_all
|
34
26
|
</pre>
|
35
27
|
|
28
|
+
This will install resources such as:
|
29
|
+
<ul>
|
30
|
+
<li>Models</li>
|
31
|
+
<li>Controllers</li>
|
32
|
+
<li>Views</li>
|
33
|
+
<li>Helpers</li>
|
34
|
+
<li>Migrations</li>
|
35
|
+
<li>Routes</li>
|
36
|
+
</ul>
|
37
|
+
|
38
|
+
Please refer to the <a href="generator.html">generator page</a> for more detail.
|
39
|
+
|
36
40
|
I recommend reading this page to get a feel for Lockdown's functionality.
|
37
41
|
|
38
42
|
h2. How it works
|
@@ -136,6 +140,50 @@ Lockdown::System.configure do
|
|
136
140
|
end
|
137
141
|
</pre>
|
138
142
|
|
143
|
+
h2. The internals
|
144
|
+
|
145
|
+
All configuration of Lockdown (Permissions and User Groups) are done in lib/lockdown/init.rb. The database functionality is merely an extension of the definitions to allow for the dynamic creation of User Groups. Permissions can not be created via the administration screens.
|
146
|
+
|
147
|
+
Lockdown doesn't have a concept of Roles. Instead, Lockdown users can be associated to one or many User Groups to allow for flexibility. In addition, you can use the admin screens to add new User Groups to the database.
|
148
|
+
|
149
|
+
Here are the parts to Lockdown:
|
150
|
+
<ul>
|
151
|
+
<li><strong>Profiles</strong><br/>
|
152
|
+
<p>The profile model contains all non-user information related to person. Lockdown uses the profile record as the reference for updated_by and created_by. This allows you to remove the user record completely when you want to revoke access, but you still retain the foreign key for history.<br/>Here are the fields you have to start with:</p>
|
153
|
+
<ul>
|
154
|
+
<li>first_name : string</li>
|
155
|
+
<li>last_name : string</li>
|
156
|
+
<li>email : string</li>
|
157
|
+
</ul>
|
158
|
+
<br/>
|
159
|
+
</li>
|
160
|
+
<li><strong>Users</strong><br/>
|
161
|
+
<p>The user model contains all user information related to person.<br/>Here are the fields you have to start with:</p>
|
162
|
+
<ul>
|
163
|
+
<li>login : string</li>
|
164
|
+
<li>crypted_password : string</li>
|
165
|
+
<li>salt : string</li>
|
166
|
+
<li>profile_id : integer</li>
|
167
|
+
</ul>
|
168
|
+
<br/>
|
169
|
+
</li>
|
170
|
+
<li><strong>User Groups</strong><br/>
|
171
|
+
<p>User Groups exist only to group Permissions. All functionality for your site should be covered by the user groups you define in init.rb. You can use the admin screen to create new user groups if the need arises. The database model only has one field: </p>
|
172
|
+
<ul>
|
173
|
+
<li>name : string</li>
|
174
|
+
</ul>
|
175
|
+
<br/>
|
176
|
+
</li>
|
177
|
+
<li><strong>Permissions</strong><br/>
|
178
|
+
<p>Permissions are the security building blocks of your system and are defined in init.rb. A permission maps to controller(s)/action(s) in your system. Please refer back to the documenation in init.rb on how to create permissions.
|
179
|
+
As permissions relate to system functionality, they cannot be created via the admin screen. The database model only has one field: </p>
|
180
|
+
<ul>
|
181
|
+
<li>name : string</li>
|
182
|
+
</ul>
|
183
|
+
</li>
|
184
|
+
</ul>
|
185
|
+
|
186
|
+
|
139
187
|
h2. Forum
|
140
188
|
|
141
189
|
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.12
|
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-05-
|
12
|
+
date: 2008-05-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|