lockdown 0.4.6 → 0.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.
Files changed (48) hide show
  1. data/Manifest.txt +39 -0
  2. data/lib/lockdown/controller.rb +3 -3
  3. data/lib/lockdown/system.rb +1 -5
  4. data/lib/lockdown/version.rb +2 -2
  5. data/rails_generators/lockdown/USAGE +5 -0
  6. data/rails_generators/lockdown/lockdown_generator.rb +221 -0
  7. data/rails_generators/lockdown/templates/app/controllers/permissions_controller.rb +22 -0
  8. data/rails_generators/lockdown/templates/app/controllers/sessions_controller.rb +38 -0
  9. data/rails_generators/lockdown/templates/app/controllers/user_groups_controller.rb +113 -0
  10. data/rails_generators/lockdown/templates/app/controllers/users_controller.rb +124 -0
  11. data/rails_generators/lockdown/templates/app/helpers/permissions_helper.rb +13 -0
  12. data/rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb +35 -0
  13. data/rails_generators/lockdown/templates/app/helpers/users_helper.rb +78 -0
  14. data/rails_generators/lockdown/templates/app/models/permission.rb +13 -0
  15. data/rails_generators/lockdown/templates/app/models/profile.rb +10 -0
  16. data/rails_generators/lockdown/templates/app/models/user.rb +72 -0
  17. data/rails_generators/lockdown/templates/app/models/user_group.rb +15 -0
  18. data/rails_generators/lockdown/templates/app/views/permissions/_data.html.erb +13 -0
  19. data/rails_generators/lockdown/templates/app/views/permissions/index.html.erb +16 -0
  20. data/rails_generators/lockdown/templates/app/views/permissions/show.html.erb +3 -0
  21. data/rails_generators/lockdown/templates/app/views/sessions/new.html.erb +12 -0
  22. data/rails_generators/lockdown/templates/app/views/user_groups/_data.html.erb +44 -0
  23. data/rails_generators/lockdown/templates/app/views/user_groups/_form.html.erb +11 -0
  24. data/rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb +6 -0
  25. data/rails_generators/lockdown/templates/app/views/user_groups/index.html.erb +20 -0
  26. data/rails_generators/lockdown/templates/app/views/user_groups/new.html.erb +5 -0
  27. data/rails_generators/lockdown/templates/app/views/user_groups/show.html.erb +6 -0
  28. data/rails_generators/lockdown/templates/app/views/users/_data.html.erb +62 -0
  29. data/rails_generators/lockdown/templates/app/views/users/_form.html.erb +18 -0
  30. data/rails_generators/lockdown/templates/app/views/users/_password.html.erb +5 -0
  31. data/rails_generators/lockdown/templates/app/views/users/edit.html.erb +6 -0
  32. data/rails_generators/lockdown/templates/app/views/users/index.html.erb +22 -0
  33. data/rails_generators/lockdown/templates/app/views/users/new.html.erb +5 -0
  34. data/rails_generators/lockdown/templates/app/views/users/show.html.erb +4 -0
  35. data/rails_generators/lockdown/templates/db/migrate/create_admin_user_and_user_group.rb +19 -0
  36. data/rails_generators/lockdown/templates/db/migrate/create_permissions.rb +19 -0
  37. data/rails_generators/lockdown/templates/db/migrate/create_profiles.rb +26 -0
  38. data/rails_generators/lockdown/templates/db/migrate/create_user_groups.rb +19 -0
  39. data/rails_generators/lockdown/templates/db/migrate/create_users.rb +17 -0
  40. data/rails_generators/lockdown_all/lockdown_all_generator.rb +0 -2
  41. data/test/test_generator_helper.rb +10 -1
  42. data/test/test_lockdown_generator.rb +11 -9
  43. data/website/generator.html +243 -0
  44. data/website/generator.txt +174 -0
  45. data/website/index.html +331 -0
  46. data/website/index.txt +62 -26
  47. data/website/model.jpg +0 -0
  48. metadata +42 -2
@@ -0,0 +1,331 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ Lockdown
9
+ </title>
10
+ <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
+ <style>
12
+
13
+ </style>
14
+ <script type="text/javascript">
15
+ window.onload = function() {
16
+ settings = {
17
+ tl: { radius: 10 },
18
+ tr: { radius: 10 },
19
+ bl: { radius: 10 },
20
+ br: { radius: 10 },
21
+ antiAlias: true,
22
+ autoPad: true,
23
+ validTags: ["div"]
24
+ }
25
+ var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
+ versionBox.applyCornersToAll();
27
+ }
28
+ </script>
29
+ </head>
30
+ <body>
31
+ <div id="main">
32
+
33
+ <h1>Lockdown</h1>
34
+ <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
35
+ <p>Get Version</p>
36
+ <a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.0</a>
37
+ </div>
38
+ <h2>What</h2>
39
+
40
+
41
+ <p>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.</p>
42
+
43
+
44
+ <h2>Installing</h2>
45
+
46
+
47
+ <pre>
48
+ $ sudo gem install lockdown
49
+ $ cd &lt;your_project_directory&gt;
50
+ $ lockdown .
51
+ </pre>
52
+
53
+ <p>This will create a &#8220;lockdown&#8221; directory in the lib dir add two files: init.rb and session.rb.
54
+ Modify init.rb to set configuration options and define the permissions and user groups that apply to your system.</p>
55
+
56
+
57
+ <p><strong> Please keep the following in mind:</strong>
58
+ <ul>
59
+ <li><strong>All Permissions are defined in init.rb, they cannot be defined via the administration screens.</strong></li>
60
+ <li><strong>All User Groups should be defined in init.rb. The administration screens can be used to create user groups, but doing so should be reserved for the unexpected. Creating User Groups via the administration screens will only add more work for you if you want to run tests using those groups.</strong></li>
61
+ <li><strong>Lockdown will sync up the rules (Permissions and User Groups) defined in init.rb with your database. You can turn off this feature.</strong></li>
62
+ </ul></p>
63
+
64
+
65
+ <p>To help you with your new application, Lockdown comes with a generator called lockdown that has various options for you to pick which templates you desire.</p>
66
+
67
+
68
+ <pre>
69
+ $ cd &lt;your_project_directory&gt;
70
+ $ ./script/generate lockdown --all
71
+ </pre>
72
+
73
+ This will install resources such as:
74
+ <ul>
75
+ <li>Models</li>
76
+ <li>Controllers</li>
77
+ <li>Views</li>
78
+ <li>Helpers</li>
79
+ <li>Migrations</li>
80
+ <li>Routes</li>
81
+ </ul>
82
+
83
+ <p>Please refer to the <a href="generator.html">generator page</a> for more detail.</p>
84
+
85
+
86
+ <h2>How it works</h2>
87
+
88
+
89
+ When Lockdown is installed, it adds the following line to your environment.rb (init.rb for Merb):
90
+ <pre>
91
+ require "lockdown/init"
92
+ </pre>
93
+ This is the default init.rb included with Lockdown:
94
+ <pre class='syntax'>
95
+ <span class="ident">require</span> <span class="punct">&quot;</span><span class="string">lockdown</span><span class="punct">&quot;</span>
96
+ <span class="ident">require</span> <span class="constant">File</span><span class="punct">.</span><span class="ident">join</span><span class="punct">(</span><span class="constant">File</span><span class="punct">.</span><span class="ident">dirname</span><span class="punct">(</span><span class="constant">__FILE__</span><span class="punct">),</span> <span class="punct">&quot;</span><span class="string">session</span><span class="punct">&quot;)</span>
97
+
98
+ <span class="constant">Lockdown</span><span class="punct">::</span><span class="constant">System</span><span class="punct">.</span><span class="ident">configure</span> <span class="keyword">do</span>
99
+
100
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
101
+ <span class="comment"># Configuration Options</span>
102
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
103
+ <span class="comment"># Options with defaults:</span>
104
+ <span class="comment">#</span>
105
+ <span class="comment"># Set timeout to 1 hour:</span>
106
+ <span class="comment"># options[:session_timeout] = (60 * 60)</span>
107
+ <span class="comment">#</span>
108
+ <span class="comment"># Set system to logout if unauthorized access is attempted:</span>
109
+ <span class="comment"># options[:logout_on_access_violation] = false</span>
110
+ <span class="comment">#</span>
111
+ <span class="comment"># Set redirect to path on unauthorized access attempt:</span>
112
+ <span class="comment"># options[:access_denied_path] = &quot;/&quot;</span>
113
+ <span class="comment">#</span>
114
+ <span class="comment"># Set redirect to path on successful login:</span>
115
+ <span class="comment"># options[:successful_login_path] = &quot;/&quot;</span>
116
+ <span class="comment">#</span>
117
+ <span class="comment"># Set the system to sync the Permissions and UserGroups defined here</span>
118
+ <span class="comment"># with the database. </span>
119
+ <span class="comment"># options[:sync_init_rb_with_db] = true</span>
120
+ <span class="comment">#</span>
121
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
122
+ <span class="comment"># Define permissions</span>
123
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
124
+ <span class="comment">#</span>
125
+ <span class="comment"># set_permission(:product_management, all_methods(:products))</span>
126
+ <span class="comment">#</span>
127
+ <span class="comment"># :product_management is the name of the permission which is later</span>
128
+ <span class="comment"># referenced by the set_user_group method</span>
129
+ <span class="comment">#</span>
130
+ <span class="comment"># :all_methods(:products) will return an array of all controller actions</span>
131
+ <span class="comment"># for the products controller</span>
132
+ <span class="comment">#</span>
133
+ <span class="comment"># if products is your standard RESTful resource you'll get:</span>
134
+ <span class="comment"># [&quot;products/index , &quot;products/show&quot;,</span>
135
+ <span class="comment"># &quot;products/new&quot;, &quot;products/edit&quot;,</span>
136
+ <span class="comment"># &quot;products/create&quot;, &quot;products/update&quot;,</span>
137
+ <span class="comment"># &quot;products/destroy&quot;]</span>
138
+ <span class="comment">#</span>
139
+ <span class="comment"># You can pass multiple parameters to concat permissions such as:</span>
140
+ <span class="comment"># </span>
141
+ <span class="comment"># set_permission(:security_management,all_methods(:users),</span>
142
+ <span class="comment"># all_methods(:user_groups),</span>
143
+ <span class="comment"># all_methods(:permissions) )</span>
144
+ <span class="comment">#</span>
145
+ <span class="comment"># In addition to all_methods(:controller) there are:</span>
146
+ <span class="comment">#</span>
147
+ <span class="comment"># only_methods(:controller, :only_method_1, :only_method_2)</span>
148
+ <span class="comment">#</span>
149
+ <span class="comment"># all_except_methods(:controller, :except_method_1, :except_method_2)</span>
150
+ <span class="comment">#</span>
151
+ <span class="comment"># Some other sample permissions:</span>
152
+ <span class="comment"># </span>
153
+ <span class="comment"># set_permission(:sessions, all_methods(:sessions))</span>
154
+ <span class="comment"># set_permission(:my_account, only_methods(:users, :edit, :update, :show))</span>
155
+ <span class="comment"># </span>
156
+ <span class="comment"># Define your permissions here:</span>
157
+
158
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
159
+ <span class="comment"># Built-in user groups</span>
160
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
161
+ <span class="comment"># You can assign the above permission to one of the built-in user groups</span>
162
+ <span class="comment"># by using the following:</span>
163
+ <span class="comment"># </span>
164
+ <span class="comment"># To allow public access on the permissions :sessions and :home:</span>
165
+ <span class="comment"># set_public_access :sessions, :home</span>
166
+ <span class="comment"># </span>
167
+ <span class="comment"># Restrict :my_account access to only authenticated users:</span>
168
+ <span class="comment"># set_protected_access :my_account</span>
169
+ <span class="comment">#</span>
170
+ <span class="comment"># Define the built-in user groups here:</span>
171
+
172
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
173
+ <span class="comment"># Define user groups</span>
174
+ <span class="comment">#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
175
+ <span class="comment">#</span>
176
+ <span class="comment"># set_user_group(:catalog_management, :category_management, </span>
177
+ <span class="comment"># :product_management) </span>
178
+ <span class="comment">#</span>
179
+ <span class="comment"># :catalog_management is the name of the user group</span>
180
+ <span class="comment"># :category_management and :product_management refer to permission names</span>
181
+ <span class="comment">#</span>
182
+ <span class="comment"># </span>
183
+ <span class="comment"># Define your user groups here:</span>
184
+
185
+ <span class="keyword">end</span>
186
+ </pre>
187
+
188
+ As you can see, the first line requires lockdown. This will load the Lockdown system which consists of various parts:
189
+ <ul>
190
+ <li>
191
+ Controller<br/>
192
+ <p>The controller functionality will add before filters to test each request agains the defined access_rights for the current user. If the current request is not in the access_rights list, access right is denied.</p>
193
+ </li>
194
+ <li>
195
+ Model<br/>
196
+ <p>The model functionality will automatically set the updated_by/created_by fields of your model to the current_profile_id.</p>
197
+ </li>
198
+ <li>
199
+ View<br/>
200
+ <p>The view functionality intercepts the link_to method (aliases it). If the current user does not have rights to the link, the link will not show.<br/>There is also a link_to_or_show method (same params as link_to) that will print out just the name of the link (no anchor tag) if the current user does not have access. </p>
201
+ </li>
202
+ </ul>
203
+
204
+ When referring to access rights: if you have a standard <span class="caps">REST</span> users controller, the access rights would be:
205
+ <pre>
206
+ users/index
207
+ users/show
208
+ users/edit
209
+ users/update
210
+ users/new
211
+ users/create
212
+ users/destroy (delete for Merb)
213
+ </pre>
214
+
215
+ <h2>The internals</h2>
216
+
217
+
218
+ <p>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.</p>
219
+
220
+
221
+ <p>Lockdown doesn&#8217;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. User groups are nothing more than a grouping mechanism for Permissions to ease management.</p>
222
+
223
+
224
+ <p>Here are the parts to Lockdown:</p>
225
+
226
+
227
+ <div style="text-align:center">
228
+ <img src="model.jpg" alt="" />
229
+ </div>
230
+
231
+ <ul>
232
+ <li><strong>Profiles</strong><br/>
233
+ <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>
234
+ <ul>
235
+ <li>first_name : string</li>
236
+ <li>last_name : string</li>
237
+ <li>email : string</li>
238
+ </ul>
239
+ <br/>
240
+ </li>
241
+ <li><strong>Users</strong><br/>
242
+ <p>The user model contains all user information related to person.<br/>Here are the fields you have to start with:</p>
243
+ <ul>
244
+ <li>login : string</li>
245
+ <li>crypted_password : string</li>
246
+ <li>salt : string</li>
247
+ <li>profile_id : integer</li>
248
+ </ul>
249
+ <br/>
250
+ </li>
251
+ <li><strong>User Groups</strong><br/>
252
+ <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>
253
+ <ul>
254
+ <li>name : string</li>
255
+ </ul>
256
+ <br/>
257
+ </li>
258
+ <li><strong>Permissions</strong><br/>
259
+ <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.
260
+ As permissions relate to system functionality, they cannot be created via the admin screen. The database model only has one field: </p>
261
+ <ul>
262
+ <li>name : string</li>
263
+ </ul>
264
+ </li>
265
+ </ul>
266
+
267
+ <h2>Roadmap to 1.0</h2>
268
+
269
+
270
+ <p><strong>**this is tentative and the feature order may change</strong></p>
271
+
272
+
273
+ <ul>
274
+ <li><strong>0.5.0: </strong>More generators to ease installation into existing projects</li>
275
+ <li><strong>0.6.0: </strong>Password reset/reminder, Registration page template generators</li>
276
+ <li><strong>0.7.0: </strong>OpenId support</li>
277
+ <li><strong>0.8.0: </strong>RSpec tests and helper methods for your application</li>
278
+ <li><strong>0.9.0: </strong>Merb Support</li>
279
+ <li><strong>1.0.0: </strong>Model level security</li>
280
+ </ul>
281
+
282
+ <h2>Google Group</h2>
283
+
284
+
285
+ <p>If you are having a problem understanding how to use Lockdown, please post your question on the lockdown group. If it&#8217;s documentation related, I will keep this page updated to help everyone.</p>
286
+
287
+
288
+ <p><a href="http://groups.google.com/group/stonean_lockdown?hl=en">http://groups.google.com/group/stonean_lockdown?hl=en</a></p>
289
+
290
+
291
+ <h2>How to submit patches</h2>
292
+
293
+
294
+ <p>The Clone <span class="caps">URL</span>: git://github.com/stonean/lockdown.git</p>
295
+
296
+
297
+ <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
298
+
299
+
300
+ <p>I&#8217;m new to git and this whole opensource project admin gig, so please be patient with my stumbling around.</p>
301
+
302
+
303
+ <h2>License</h2>
304
+
305
+
306
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
307
+
308
+
309
+ <h2>Contact</h2>
310
+
311
+
312
+ <p>Comments and suggestions are welcome via the <a href="http://groups.google.com/group/stonean_lockdown?hl=en">google group</a></p>
313
+
314
+
315
+ <p><a href="http://blog.stonean.com">Andrew Stone</a></p>
316
+ <p class="coda">
317
+ 22nd May 2008<br/>
318
+ Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
319
+ </p>
320
+ </div>
321
+ <script type="text/javascript">
322
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
323
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
324
+ </script>
325
+ <script type="text/javascript">
326
+ var pageTracker = _gat._getTracker("UA-4189092-1");
327
+ pageTracker._initData();
328
+ pageTracker._trackPageview();
329
+ </script>
330
+ </body>
331
+ </html>
data/website/index.txt CHANGED
@@ -2,33 +2,31 @@ h1. <a href="http://lockdown.rubyforge.org">Lockdown</a>
2
2
 
3
3
  h2. What
4
4
 
5
- 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.
5
+ 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.
6
6
 
7
7
  h2. Installing
8
8
 
9
- For the people who don't care to know the details and just want to get the system installed:
10
-
11
9
  <pre>
12
10
  $ sudo gem install lockdown
13
11
  $ cd <your_project_directory>
14
12
  $ lockdown .
15
13
  </pre>
16
14
 
17
- 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.
15
+ This will create a "lockdown" directory in the lib dir add two files: init.rb and session.rb.
16
+ Modify init.rb to set configuration options and define the permissions and user groups that apply to your system.
18
17
 
19
- <strong> Some noteworthy points:</strong>
18
+ <strong> Please keep the following in mind:</strong>
20
19
  <ul>
21
20
  <li><strong>All Permissions are defined in init.rb, they cannot be defined via the administration screens.</strong></li>
22
- <li><strong>All User Groups should be defined in init.rb. The administration screens can be used to create user groups, but doing so should be reserved for the unexpected.</strong></li>
23
- <li><strong>Lockdown will sync up the rules (Permissions and User Groups) defined in init.rb with your database.</strong></li>
21
+ <li><strong>All User Groups should be defined in init.rb. The administration screens can be used to create user groups, but doing so should be reserved for the unexpected. Creating User Groups via the administration screens will only add more work for you if you want to run tests using those groups.</strong></li>
22
+ <li><strong>Lockdown will sync up the rules (Permissions and User Groups) defined in init.rb with your database. You can turn off this feature.</strong></li>
24
23
  </ul>
25
24
 
26
-
27
- To help you with your new application, Lockdown comes with a generator called lockdown_all.
25
+ To help you with your new application, Lockdown comes with a generator called lockdown that has various options for you to pick which templates you desire.
28
26
 
29
27
  <pre>
30
28
  $ cd <your_project_directory>
31
- $ ./script/generate lockdown_all
29
+ $ ./script/generate lockdown --all
32
30
  </pre>
33
31
 
34
32
  This will install resources such as:
@@ -45,20 +43,11 @@ Please refer to the <a href="generator.html">generator page</a> for more detail.
45
43
 
46
44
  h2. How it works
47
45
 
48
- Lockdown stores an array of access rights in the session. For example, if you have a standard REST users controller, the access rights would be:
46
+ When Lockdown is installed, it adds the following line to your environment.rb (init.rb for Merb):
49
47
  <pre>
50
- users/index
51
- users/show
52
- users/edit
53
- users/update
54
- users/new
55
- users/create
56
- users/destroy (delete for Merb)
48
+ require "lockdown/init"
57
49
  </pre>
58
-
59
- The above list will be stored in the session as an array and each request is tested against this list.
60
-
61
- To define access rights you need to modify lib/lockdown/init.rb. This is the default init.rb included with Lockdown:
50
+ This is the default init.rb included with Lockdown:
62
51
  <pre syntax="ruby">
63
52
  require "lockdown"
64
53
  require File.join(File.dirname(__FILE__), "session")
@@ -82,6 +71,10 @@ Lockdown::System.configure do
82
71
  # Set redirect to path on successful login:
83
72
  # options[:successful_login_path] = "/"
84
73
  #
74
+ # Set the system to sync the Permissions and UserGroups defined here
75
+ # with the database.
76
+ # options[:sync_init_rb_with_db] = true
77
+ #
85
78
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
79
  # Define permissions
87
80
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -147,14 +140,41 @@ Lockdown::System.configure do
147
140
  # Define your user groups here:
148
141
 
149
142
  end
150
-
151
143
  </pre>
152
144
 
145
+ As you can see, the first line requires lockdown. This will load the Lockdown system which consists of various parts:
146
+ <ul>
147
+ <li>
148
+ Controller<br/>
149
+ <p>The controller functionality will add before filters to test each request agains the defined access_rights for the current user. If the current request is not in the access_rights list, access right is denied.</p>
150
+ </li>
151
+ <li>
152
+ Model<br/>
153
+ <p>The model functionality will automatically set the updated_by/created_by fields of your model to the current_profile_id.</p>
154
+ </li>
155
+ <li>
156
+ View<br/>
157
+ <p>The view functionality intercepts the link_to method (aliases it). If the current user does not have rights to the link, the link will not show.<br/>There is also a link_to_or_show method (same params as link_to) that will print out just the name of the link (no anchor tag) if the current user does not have access. </p>
158
+ </li>
159
+ </ul>
160
+
161
+ When referring to access rights: if you have a standard REST users controller, the access rights would be:
162
+ <pre>
163
+ users/index
164
+ users/show
165
+ users/edit
166
+ users/update
167
+ users/new
168
+ users/create
169
+ users/destroy (delete for Merb)
170
+ </pre>
171
+
172
+
153
173
  h2. The internals
154
174
 
155
175
  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.
156
176
 
157
- 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.
177
+ 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. User groups are nothing more than a grouping mechanism for Permissions to ease management.
158
178
 
159
179
  Here are the parts to Lockdown:
160
180
 
@@ -198,7 +218,20 @@ Here are the parts to Lockdown:
198
218
  </li>
199
219
  </ul>
200
220
 
201
- h2. Forum
221
+ h2. Roadmap to 1.0
222
+
223
+ <strong>**this is tentative and the feature order may change</strong>
224
+
225
+ <ul>
226
+ <li><strong>0.5.0: </strong>More generators to ease installation into existing projects</li>
227
+ <li><strong>0.6.0: </strong>Password reset/reminder, Registration page template generators</li>
228
+ <li><strong>0.7.0: </strong>OpenId support</li>
229
+ <li><strong>0.8.0: </strong>RSpec tests and helper methods for your application</li>
230
+ <li><strong>0.9.0: </strong>Merb Support</li>
231
+ <li><strong>1.0.0: </strong>Model level security</li>
232
+ </ul>
233
+
234
+ h2. Google Group
202
235
 
203
236
  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.
204
237
 
@@ -217,7 +250,10 @@ h2. License
217
250
 
218
251
  This code is free to use under the terms of the MIT license.
219
252
 
253
+
220
254
  h2. Contact
221
255
 
222
- Comments and suggestions are welcome via the "forum":http://groups.google.com/group/stonean_lockdown?hl=en
256
+ Comments and suggestions are welcome via the "google group":http://groups.google.com/group/stonean_lockdown?hl=en
257
+
258
+ <a href="http://blog.stonean.com">Andrew Stone</a>
223
259
 
data/website/model.jpg ADDED
Binary file
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.4.6
4
+ version: 0.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: 2008-05-08 00:00:00 -04:00
12
+ date: 2008-05-22 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,7 @@ extra_rdoc_files:
34
34
  - Manifest.txt
35
35
  - PostInstall.txt
36
36
  - README.txt
37
+ - website/generator.txt
37
38
  - website/index.txt
38
39
  files:
39
40
  - History.txt
@@ -59,6 +60,41 @@ files:
59
60
  - lib/lockdown/system.rb
60
61
  - lib/lockdown/version.rb
61
62
  - lib/lockdown/view.rb
63
+ - rails_generators/lockdown/USAGE
64
+ - rails_generators/lockdown/lockdown_generator.rb
65
+ - rails_generators/lockdown/templates/app/controllers/permissions_controller.rb
66
+ - rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
67
+ - rails_generators/lockdown/templates/app/controllers/user_groups_controller.rb
68
+ - rails_generators/lockdown/templates/app/controllers/users_controller.rb
69
+ - rails_generators/lockdown/templates/app/helpers/permissions_helper.rb
70
+ - rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb
71
+ - rails_generators/lockdown/templates/app/helpers/users_helper.rb
72
+ - rails_generators/lockdown/templates/app/models/permission.rb
73
+ - rails_generators/lockdown/templates/app/models/profile.rb
74
+ - rails_generators/lockdown/templates/app/models/user.rb
75
+ - rails_generators/lockdown/templates/app/models/user_group.rb
76
+ - rails_generators/lockdown/templates/app/views/permissions/_data.html.erb
77
+ - rails_generators/lockdown/templates/app/views/permissions/index.html.erb
78
+ - rails_generators/lockdown/templates/app/views/permissions/show.html.erb
79
+ - rails_generators/lockdown/templates/app/views/sessions/new.html.erb
80
+ - rails_generators/lockdown/templates/app/views/user_groups/_data.html.erb
81
+ - rails_generators/lockdown/templates/app/views/user_groups/_form.html.erb
82
+ - rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb
83
+ - rails_generators/lockdown/templates/app/views/user_groups/index.html.erb
84
+ - rails_generators/lockdown/templates/app/views/user_groups/new.html.erb
85
+ - rails_generators/lockdown/templates/app/views/user_groups/show.html.erb
86
+ - rails_generators/lockdown/templates/app/views/users/_data.html.erb
87
+ - rails_generators/lockdown/templates/app/views/users/_form.html.erb
88
+ - rails_generators/lockdown/templates/app/views/users/_password.html.erb
89
+ - rails_generators/lockdown/templates/app/views/users/edit.html.erb
90
+ - rails_generators/lockdown/templates/app/views/users/index.html.erb
91
+ - rails_generators/lockdown/templates/app/views/users/new.html.erb
92
+ - rails_generators/lockdown/templates/app/views/users/show.html.erb
93
+ - rails_generators/lockdown/templates/db/migrate/create_admin_user_and_user_group.rb
94
+ - rails_generators/lockdown/templates/db/migrate/create_permissions.rb
95
+ - rails_generators/lockdown/templates/db/migrate/create_profiles.rb
96
+ - rails_generators/lockdown/templates/db/migrate/create_user_groups.rb
97
+ - rails_generators/lockdown/templates/db/migrate/create_users.rb
62
98
  - rails_generators/lockdown_all/USAGE
63
99
  - rails_generators/lockdown_all/lockdown_all_generator.rb
64
100
  - rails_generators/lockdown_all/templates/app/controllers/permissions_controller.rb
@@ -108,8 +144,12 @@ files:
108
144
  - test/test_lockdown_all_generator.rb
109
145
  - test/test_lockdown_generator.rb
110
146
  - test/test_lockdown_models_generator.rb
147
+ - website/generator.html
148
+ - website/generator.txt
149
+ - website/index.html
111
150
  - website/index.txt
112
151
  - website/javascripts/rounded_corners_lite.inc.js
152
+ - website/model.jpg
113
153
  - website/stylesheets/screen.css
114
154
  - website/template.html.erb
115
155
  has_rdoc: true