lockdown 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'fileutils'
3
+
4
+ # Must set before requiring generator libs.
5
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
6
+ PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
7
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
8
+ if defined?(APP_ROOT)
9
+ APP_ROOT.replace(app_root)
10
+ else
11
+ APP_ROOT = app_root
12
+ end
13
+
14
+ begin
15
+ require 'rubigen'
16
+ rescue LoadError
17
+ require 'rubygems'
18
+ require 'rubigen'
19
+ end
20
+ require 'rubigen/helpers/generator_test_helper'
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/lockdown'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestLockdown < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestLockdownGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup
7
+ bare_setup
8
+ end
9
+
10
+ def teardown
11
+ bare_teardown
12
+ end
13
+
14
+ # Some generator-related assertions:
15
+ # assert_generated_file(name, &block) # block passed the file contents
16
+ # assert_directory_exists(name)
17
+ # assert_generated_class(name, &block)
18
+ # assert_generated_module(name, &block)
19
+ # assert_generated_test_for(name, &block)
20
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
21
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
22
+ #
23
+ # Other helper methods are:
24
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
+
28
+ def test_generator_without_options
29
+ run_generator('lockdown', [APP_ROOT], sources)
30
+ assert_directory_exists "path/to/included/folder"
31
+ assert_generated_file "path/to/included/folder/some_file"
32
+ end
33
+
34
+ private
35
+ def sources
36
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
37
+ ]
38
+ end
39
+
40
+ def generator_path
41
+ "app_generators"
42
+ end
43
+ end
@@ -0,0 +1,302 @@
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.1.0</a>
37
+ </div>
38
+ <h1>&#x2192; &#8216;lockdown&#8217;</h1>
39
+
40
+
41
+ <h3>Lockdown has not been officially released! This page is a Work-In-Progress. The first version will be released by May 1st.</h3>
42
+
43
+
44
+ <h2>What</h2>
45
+
46
+
47
+ <p>Lockdown is a authentication/authorization system for RubyOnRails and Merb designed for simplicity and extensibility. All access rules are in (initially) defined in lib/lockdown/access.rb. With the included <span class="caps">ORM</span> support (ActiveRecord or DataMapper) and management screens you can add user defined rules to the system.</p>
48
+
49
+
50
+ <p>If there is a &#8220;spec&#8221; 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.</p>
51
+
52
+
53
+ <p>Also included is functionality to auto-populate created_by and updated_by fields.</p>
54
+
55
+
56
+ <p>Some model level access right functionality will also be added in the near future.</p>
57
+
58
+
59
+ <h2>Installing</h2>
60
+
61
+
62
+ <p>For the people who don&#8217;t care to know the details and just want to get the system installed:</p>
63
+
64
+
65
+ <pre>
66
+ $ sudo gem install lockdown
67
+ $ cd &lt;your_project_directory&gt;
68
+ $ lockdown .
69
+ </pre>
70
+
71
+ <p>This will create a &#8220;lockdown&#8221; directory in the lib dir add two files: access.rb and session.rb. Modify access.rb to define the rules that apply to your system.</p>
72
+
73
+
74
+ <p>I recommend reading this page to get a feel for Lockdown&#8217;s functionality.</p>
75
+
76
+
77
+ <h2>How it works</h2>
78
+
79
+
80
+ Lockdown stores an array of access rights in the session. For example, if you have a standard <span class="caps">REST</span> users controller, the access rights would be:
81
+ <pre>
82
+ users/index
83
+ users/show
84
+ users/edit
85
+ users/update
86
+ users/new
87
+ users/create
88
+ users/destroy (delete for Merb)
89
+ </pre>
90
+
91
+ <p>The above list will be stored in the session as an array and each request is tested against this list. So this means, you <strong>should not use client side session storage</strong>. If you can, I recommend using memcache, but a database session store will suffice.</p>
92
+
93
+
94
+ <p>To define access rights you need to modify lib/lockdown/access.rb. This is the default access.rb included with Lockdown:
95
+ <pre class='syntax'>
96
+ <span class="ident">require</span> <span class="punct">&quot;</span><span class="string">lockdown</span><span class="punct">&quot;</span>
97
+
98
+ <span class="keyword">module </span><span class="module">Lockdown</span>
99
+ <span class="comment">#</span>
100
+ <span class="comment">#</span>
101
+ <span class="comment"># Permissions are used to group access rights into logical components.</span>
102
+ <span class="comment"># Each method defined in the Permissions module represents an array</span>
103
+ <span class="comment"># of methods from a controller (or multiple controllers.)</span>
104
+ <span class="comment"># </span>
105
+ <span class="comment"># Controller methods available are: </span>
106
+ <span class="comment">#</span>
107
+ <span class="comment"># # Returns all methods from all controllers</span>
108
+ <span class="comment"># all_controllers</span>
109
+ <span class="comment"># </span>
110
+ <span class="comment"># # Returns all methods from all controllers listed</span>
111
+ <span class="comment"># all_methods :controller1, controller2, ...</span>
112
+ <span class="comment"># </span>
113
+ <span class="comment"># # For a single controller, returns only methods listed</span>
114
+ <span class="comment"># only_methods :controller1, :method1, :method2, ...</span>
115
+ <span class="comment"># </span>
116
+ <span class="comment"># # For a single controller, returns all methods except the methods listed</span>
117
+ <span class="comment"># all_except_methods :controller1, :method1, :method2, ...</span>
118
+ <span class="comment">#</span>
119
+ <span class="comment"># They all return an array of controller/action. For example, if you had a</span>
120
+ <span class="comment"># standard REST controller called products this would be the result:</span>
121
+ <span class="comment">#</span>
122
+ <span class="comment">#</span>
123
+ <span class="comment"># all_methods :products =&gt; [ &quot;products/index , &quot;products/show&quot;,</span>
124
+ <span class="comment"># &quot;products/new&quot;, &quot;products/edit&quot;,</span>
125
+ <span class="comment"># &quot;products/create&quot;, &quot;products/update&quot;,</span>
126
+ <span class="comment"># &quot;products/destroy&quot;]</span>
127
+ <span class="comment">#</span>
128
+ <span class="keyword">module </span><span class="module">Permissions</span>
129
+ <span class="keyword">class </span><span class="punct">&lt;&lt;</span> <span class="constant">self</span>
130
+
131
+ <span class="keyword">def </span><span class="method">sessions_management</span>
132
+ <span class="comment"># all_methods :sessions</span>
133
+ <span class="keyword">end</span>
134
+
135
+ <span class="keyword">end</span> <span class="comment"># end class block</span>
136
+ <span class="keyword">end</span> <span class="comment"># end Permissions module</span>
137
+
138
+ <span class="comment">#</span>
139
+ <span class="comment"># UserGroups are used to group Permissions together to define role type</span>
140
+ <span class="comment"># functionality. Users may belong to multiple groups.</span>
141
+ <span class="comment"># </span>
142
+ <span class="keyword">module </span><span class="module">UserGroups</span>
143
+ <span class="keyword">class </span><span class="punct">&lt;&lt;</span> <span class="constant">self</span>
144
+
145
+ <span class="comment">#</span>
146
+ <span class="comment"># This method defines which UserGroups cannot be managed</span>
147
+ <span class="comment"># via the management screens. </span>
148
+ <span class="comment"># </span>
149
+ <span class="comment"># Users can still be assigned to these groups.</span>
150
+ <span class="comment">#</span>
151
+ <span class="keyword">def </span><span class="method">private_records</span>
152
+ <span class="punct">[</span><span class="symbol">:administrators</span><span class="punct">]</span>
153
+ <span class="keyword">end</span>
154
+ <span class="comment">#</span>
155
+ <span class="comment"># This method defines which UserGroups have limited access</span>
156
+ <span class="comment"># via the management screens. Deletion is not allowed.</span>
157
+ <span class="comment"># </span>
158
+ <span class="comment"># Users can still be assigned to these groups.</span>
159
+ <span class="comment">#</span>
160
+ <span class="keyword">def </span><span class="method">protected_records</span>
161
+ <span class="punct">[</span><span class="symbol">:public_access</span><span class="punct">,</span> <span class="symbol">:registered_users</span><span class="punct">]</span>
162
+ <span class="keyword">end</span>
163
+
164
+ <span class="comment"># ** The administrator method is &quot;special&quot;, please don't rename.</span>
165
+ <span class="comment"># If you remove/rename, etc... YOU WILL BREAK STUFF</span>
166
+ <span class="comment">#</span>
167
+ <span class="comment"># Standard administrator user group.</span>
168
+ <span class="comment"># Please don't alter without careful consideration.</span>
169
+ <span class="comment">#</span>
170
+ <span class="keyword">def </span><span class="method">administrators</span>
171
+ <span class="punct">[</span><span class="symbol">:all</span><span class="punct">]</span>
172
+ <span class="keyword">end</span>
173
+
174
+ <span class="comment"># ** The public_access method is &quot;special&quot;, please don't rename.</span>
175
+ <span class="comment"># If you remove/rename, etc... YOU WILL BREAK STUFF</span>
176
+ <span class="comment">#</span>
177
+ <span class="comment"># Standard public_access user group. </span>
178
+ <span class="comment">#</span>
179
+ <span class="comment"># Feel free to add Permissions to the array without issue.</span>
180
+ <span class="comment">#</span>
181
+ <span class="comment"># **Notice: All permissions added to this public_access group will not be</span>
182
+ <span class="comment"># restricted to logged in users.</span>
183
+ <span class="comment"># So be careful what you add here!</span>
184
+ <span class="comment">#</span>
185
+ <span class="keyword">def </span><span class="method">public_access</span>
186
+ <span class="punct">[</span><span class="symbol">:sessions_management</span><span class="punct">]</span>
187
+ <span class="keyword">end</span>
188
+
189
+ <span class="comment"># ** The registered_users method is &quot;special&quot;, please don't rename.</span>
190
+ <span class="comment"># Not as special as the others, but still...</span>
191
+ <span class="comment">#</span>
192
+ <span class="comment"># All newly created users are assigned to this User Group by default</span>
193
+ <span class="comment">#</span>
194
+ <span class="keyword">def </span><span class="method">registered_users</span>
195
+ <span class="comment">#[:my_account]</span>
196
+ <span class="keyword">end</span>
197
+
198
+ <span class="comment">#</span>
199
+ <span class="comment"># Define your own user groups below</span>
200
+ <span class="comment">#</span>
201
+ <span class="keyword">end</span> <span class="comment"># end class block</span>
202
+ <span class="keyword">end</span> <span class="comment"># end UserGroups module</span>
203
+ <span class="keyword">end</span> <span class="comment"># end Lockdown module</span>
204
+ </pre></p>
205
+
206
+
207
+ <h2>Some History</h2>
208
+
209
+
210
+ <p>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&#8217;t like the static methodology of using code scattered amongst the controllers to define my access rights for the system. I also didn&#8217;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.</p>
211
+
212
+
213
+ <p>The system was nice and worked well until I had a project that required RSpec tests. I don&#8217;t have anything against testing frameworks (now that I&#8217;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.</p>
214
+
215
+
216
+ <blockquote>This is where the access.rb file was born. This file contains the rules that grant/deny access to your system. More on this later.</blockquote>
217
+
218
+ <p>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.</p>
219
+
220
+
221
+ <p>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.</p>
222
+
223
+
224
+ <p>There is code in place for using Lockdown with Rails, after all, that&#8217;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.</p>
225
+
226
+
227
+ <p>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&#8217;t be well received by the general public. In addition, if you don&#8217;t make things easy, the adoption rate will probably be non-existent.</p>
228
+
229
+
230
+ <h2>Features</h2>
231
+
232
+
233
+ <p><strong>I have these components (for the most part)...figuring out how to package them. The following is just an idea right now&#8230; </strong>
234
+ <br/>
235
+ <br/>
236
+ The goal of Lockdown is to give you only what you want from the system.</p>
237
+
238
+
239
+ <p>The initial install is all that is required to lock down your system. However, you&#8217;ll probably want the authorization functionality. You can get this by:</p>
240
+
241
+
242
+ <p><pre class='syntax'><span class="ident">rake</span> <span class="ident">lockdown</span><span class="symbol">:install:authorization</span></pre></p>
243
+
244
+
245
+ <p>If you want to install <span class="caps">ORM</span> support:</p>
246
+
247
+
248
+ <p><pre class='syntax'><span class="ident">rake</span> <span class="ident">lockdown</span><span class="symbol">:install:orm</span></pre></p>
249
+
250
+
251
+ <p>If you want to install management screens (ORM support included):
252
+ <pre class='syntax'><span class="ident">rake</span> <span class="ident">lockdown</span><span class="symbol">:install:management</span></pre></p>
253
+
254
+
255
+ <p>If you want to install authorization + management screens:
256
+ <pre class='syntax'><span class="ident">rake</span> <span class="ident">lockdown</span><span class="symbol">:install:all</span></pre></p>
257
+
258
+
259
+ <h2>Forum</h2>
260
+
261
+
262
+ <p><a href="http://groups.google.com/group/stonean_lockdown?hl=en">http://groups.google.com/group/stonean_lockdown?hl=en</a></p>
263
+
264
+
265
+ <h2>How to submit patches</h2>
266
+
267
+
268
+ <p>The Clone <span class="caps">URL</span>: git://github.com/stonean/lockdown.git</p>
269
+
270
+
271
+ <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>
272
+
273
+
274
+ <p>I&#8217;m new to git and this whole opensource project admin gig, so please be patient with my stumbling around.</p>
275
+
276
+
277
+ <h2>License</h2>
278
+
279
+
280
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
281
+
282
+
283
+ <h2>Contact</h2>
284
+
285
+
286
+ <p>Comments and suggestions are welcome via the <a href="http://groups.google.com/group/stonean_lockdown?hl=en">forum</a></p>
287
+ <p class="coda">
288
+ 22nd April 2008<br/>
289
+ Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
290
+ </p>
291
+ </div>
292
+ <script type="text/javascript">
293
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
294
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
295
+ </script>
296
+ <script type="text/javascript">
297
+ var pageTracker = _gat._getTracker("UA-4189092-1");
298
+ pageTracker._initData();
299
+ pageTracker._trackPageview();
300
+ </script>
301
+ </body>
302
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,218 @@
1
+ h1. lockdown
2
+
3
+ h1. &#x2192; 'lockdown'
4
+
5
+ h3. Lockdown has not been officially released! This page is a Work-In-Progress. The first version will be released by May 1st.
6
+
7
+ h2. What
8
+
9
+ Lockdown is a authentication/authorization system for RubyOnRails and Merb designed for simplicity and extensibility. All access rules are in (initially) defined in lib/lockdown/access.rb. With the included ORM support (ActiveRecord or DataMapper) and management screens you can add user defined rules to the system.
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.
16
+
17
+ h2. Installing
18
+
19
+ For the people who don't care to know the details and just want to get the system installed:
20
+
21
+ <pre>
22
+ $ sudo gem install lockdown
23
+ $ cd <your_project_directory>
24
+ $ lockdown .
25
+ </pre>
26
+
27
+ This will create a "lockdown" directory in the lib dir add two files: access.rb and session.rb. Modify access.rb to define the rules that apply to your system.
28
+
29
+ I recommend reading this page to get a feel for Lockdown's functionality.
30
+
31
+ h2. How it works
32
+
33
+ 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:
34
+ <pre>
35
+ users/index
36
+ users/show
37
+ users/edit
38
+ users/update
39
+ users/new
40
+ users/create
41
+ users/destroy (delete for Merb)
42
+ </pre>
43
+
44
+ The above list will be stored in the session as an array and each request is tested against this list. So this means, you <strong>should not use client side session storage</strong>. If you can, I recommend using memcache, but a database session store will suffice.
45
+
46
+ To define access rights you need to modify lib/lockdown/access.rb. This is the default access.rb included with Lockdown:
47
+ <pre syntax="ruby">
48
+ require "lockdown"
49
+
50
+ module Lockdown
51
+ #
52
+ #
53
+ # Permissions are used to group access rights into logical components.
54
+ # Each method defined in the Permissions module represents an array
55
+ # of methods from a controller (or multiple controllers.)
56
+ #
57
+ # Controller methods available are:
58
+ #
59
+ # # Returns all methods from all controllers
60
+ # all_controllers
61
+ #
62
+ # # Returns all methods from all controllers listed
63
+ # all_methods :controller1, controller2, ...
64
+ #
65
+ # # For a single controller, returns only methods listed
66
+ # only_methods :controller1, :method1, :method2, ...
67
+ #
68
+ # # For a single controller, returns all methods except the methods listed
69
+ # all_except_methods :controller1, :method1, :method2, ...
70
+ #
71
+ # They all return an array of controller/action. For example, if you had a
72
+ # standard REST controller called products this would be the result:
73
+ #
74
+ #
75
+ # all_methods :products => [ "products/index , "products/show",
76
+ # "products/new", "products/edit",
77
+ # "products/create", "products/update",
78
+ # "products/destroy"]
79
+ #
80
+ module Permissions
81
+ class << self
82
+
83
+ def sessions_management
84
+ # all_methods :sessions
85
+ end
86
+
87
+ end # end class block
88
+ end # end Permissions module
89
+
90
+ #
91
+ # UserGroups are used to group Permissions together to define role type
92
+ # functionality. Users may belong to multiple groups.
93
+ #
94
+ module UserGroups
95
+ class << self
96
+
97
+ #
98
+ # This method defines which UserGroups cannot be managed
99
+ # via the management screens.
100
+ #
101
+ # Users can still be assigned to these groups.
102
+ #
103
+ def private_records
104
+ [:administrators]
105
+ end
106
+ #
107
+ # This method defines which UserGroups have limited access
108
+ # via the management screens. Deletion is not allowed.
109
+ #
110
+ # Users can still be assigned to these groups.
111
+ #
112
+ def protected_records
113
+ [:public_access, :registered_users]
114
+ end
115
+
116
+ # ** The administrator method is "special", please don't rename.
117
+ # If you remove/rename, etc... YOU WILL BREAK STUFF
118
+ #
119
+ # Standard administrator user group.
120
+ # Please don't alter without careful consideration.
121
+ #
122
+ def administrators
123
+ [:all]
124
+ end
125
+
126
+ # ** The public_access method is "special", please don't rename.
127
+ # If you remove/rename, etc... YOU WILL BREAK STUFF
128
+ #
129
+ # Standard public_access user group.
130
+ #
131
+ # Feel free to add Permissions to the array without issue.
132
+ #
133
+ # **Notice: All permissions added to this public_access group will not be
134
+ # restricted to logged in users.
135
+ # So be careful what you add here!
136
+ #
137
+ def public_access
138
+ [:sessions_management]
139
+ end
140
+
141
+ # ** The registered_users method is "special", please don't rename.
142
+ # Not as special as the others, but still...
143
+ #
144
+ # All newly created users are assigned to this User Group by default
145
+ #
146
+ def registered_users
147
+ #[:my_account]
148
+ end
149
+
150
+ #
151
+ # Define your own user groups below
152
+ #
153
+ end # end class block
154
+ end # end UserGroups module
155
+ end # end Lockdown module
156
+ </pre>
157
+
158
+
159
+ h2. Some History
160
+
161
+ 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.
162
+
163
+ 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.
164
+
165
+ <blockquote>This is where the access.rb file was born. This file contains the rules that grant/deny access to your system. More on this later.</blockquote>
166
+
167
+ 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.
168
+
169
+ 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.
170
+
171
+ 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.
172
+
173
+ 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.
174
+
175
+
176
+ h2. Features
177
+
178
+ <strong>I have these components (for the most part)...figuring out how to package them. The following is just an idea right now... </strong>
179
+ <br/>
180
+ <br/>
181
+ The goal of Lockdown is to give you only what you want from the system.
182
+
183
+ The initial install is all that is required to lock down your system. However, you'll probably want the authorization functionality. You can get this by:
184
+
185
+ <pre syntax="ruby">rake lockdown:install:authorization</pre>
186
+
187
+ If you want to install ORM support:
188
+
189
+ <pre syntax="ruby">rake lockdown:install:orm</pre>
190
+
191
+ If you want to install management screens (ORM support included):
192
+ <pre syntax="ruby">rake lockdown:install:management</pre>
193
+
194
+ If you want to install authorization + management screens:
195
+ <pre syntax="ruby">rake lockdown:install:all</pre>
196
+
197
+
198
+ h2. Forum
199
+
200
+ "http://groups.google.com/group/stonean_lockdown?hl=en":http://groups.google.com/group/stonean_lockdown?hl=en
201
+
202
+
203
+ h2. How to submit patches
204
+
205
+ The Clone URL: git://github.com/stonean/lockdown.git
206
+
207
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
208
+
209
+ I'm new to git and this whole opensource project admin gig, so please be patient with my stumbling around.
210
+
211
+ h2. License
212
+
213
+ This code is free to use under the terms of the MIT license.
214
+
215
+ h2. Contact
216
+
217
+ Comments and suggestions are welcome via the "forum":http://groups.google.com/group/stonean_lockdown?hl=en
218
+