lockdown 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Manifest.txt +3 -1
- data/app_generators/lockdown/templates/access.rb +3 -1
- data/app_generators/lockdown/templates/session.rb +1 -1
- data/bin/lockdown +6 -1
- data/lib/lockdown/controller.rb +1 -1
- data/lib/lockdown/version.rb +2 -2
- data/rails_generators/lockdown_all/lockdown_all_generator.rb +25 -16
- data/rails_generators/lockdown_all/templates/app/controllers/users_controller.rb +0 -2
- data/rails_generators/lockdown_all/templates/app/models/profile.rb +10 -0
- data/rails_generators/lockdown_all/templates/app/models/user_group.rb +4 -0
- data/rails_generators/lockdown_all/templates/db/migrate/create_base_user_groups.rb +11 -0
- data/rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb +6 -2
- data/rails_generators/lockdown_all/templates/db/migrate/{create_profile.rb → create_profiles.rb} +0 -2
- data/rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb +6 -2
- data/rails_generators/lockdown_all/templates/db/migrate/create_users.rb +1 -4
- data/website/index.html +1 -1
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -30,6 +30,7 @@ rails_generators/lockdown_all/templates/app/helpers/permissions_helper.rb
|
|
30
30
|
rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb
|
31
31
|
rails_generators/lockdown_all/templates/app/helpers/users_helper.rb
|
32
32
|
rails_generators/lockdown_all/templates/app/models/permission.rb
|
33
|
+
rails_generators/lockdown_all/templates/app/models/profile.rb
|
33
34
|
rails_generators/lockdown_all/templates/app/models/user.rb
|
34
35
|
rails_generators/lockdown_all/templates/app/models/user_group.rb
|
35
36
|
rails_generators/lockdown_all/templates/app/views/permissions/_data.html.erb
|
@@ -49,8 +50,9 @@ rails_generators/lockdown_all/templates/app/views/users/edit.html.erb
|
|
49
50
|
rails_generators/lockdown_all/templates/app/views/users/index.html.erb
|
50
51
|
rails_generators/lockdown_all/templates/app/views/users/new.html.erb
|
51
52
|
rails_generators/lockdown_all/templates/app/views/users/show.html.erb
|
53
|
+
rails_generators/lockdown_all/templates/db/migrate/create_base_user_groups.rb
|
52
54
|
rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb
|
53
|
-
rails_generators/lockdown_all/templates/db/migrate/
|
55
|
+
rails_generators/lockdown_all/templates/db/migrate/create_profiles.rb
|
54
56
|
rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb
|
55
57
|
rails_generators/lockdown_all/templates/db/migrate/create_users.rb
|
56
58
|
script/console
|
data/bin/lockdown
CHANGED
@@ -5,7 +5,12 @@ require "rubigen"
|
|
5
5
|
require "rubigen/scripts/generate"
|
6
6
|
require 'optparse'
|
7
7
|
|
8
|
-
|
8
|
+
if %w(-v --version).include? ARGV.first
|
9
|
+
require 'lockdown/version'
|
10
|
+
puts "#{File.basename($0)} #{Lockdown::VERSION::STRING}"
|
11
|
+
exit(0)
|
12
|
+
end
|
13
|
+
|
9
14
|
|
10
15
|
#
|
11
16
|
# Created on 2008-4-21.
|
data/lib/lockdown/controller.rb
CHANGED
data/lib/lockdown/version.rb
CHANGED
@@ -1,16 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class LockdownAllGenerator < RubiGen::Base
|
4
|
-
|
5
|
-
default_options :author => nil
|
6
|
-
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
def initialize(runtime_args, runtime_options = {})
|
10
|
-
super
|
11
|
-
usage if args.empty?
|
12
|
-
@name = args.shift
|
13
|
-
end
|
1
|
+
class LockdownAllGenerator < Rails::Generator::Base
|
2
|
+
attr_accessor :file_name
|
14
3
|
|
15
4
|
def manifest
|
16
5
|
record do |m|
|
@@ -28,11 +17,28 @@ class LockdownAllGenerator < RubiGen::Base
|
|
28
17
|
m.file "app/controllers/permissions_controller.rb", "app/controllers/permissions_controller.rb"
|
29
18
|
m.file "app/controllers/users_controller.rb", "app/controllers/users_controller.rb"
|
30
19
|
m.file "app/controllers/user_groups_controller.rb", "app/controllers/user_groups_controller.rb"
|
20
|
+
m.file "app/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
31
21
|
|
32
22
|
#Models
|
33
23
|
m.file "app/models/permission.rb", "app/models/permission.rb"
|
34
24
|
m.file "app/models/user.rb", "app/models/user.rb"
|
35
25
|
m.file "app/models/user_group.rb", "app/models/user_group.rb"
|
26
|
+
m.file "app/models/profile.rb", "app/models/profile.rb"
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
#Migrations
|
31
|
+
m.migration_template "db/migrate/create_profiles.rb", "db/migrate", :migration_file_name => "create_profiles"
|
32
|
+
m.migration_template "db/migrate/create_users.rb", "db/migrate", :migration_file_name => "create_users"
|
33
|
+
m.migration_template "db/migrate/create_user_groups.rb", "db/migrate", :migration_file_name => "create_user_groups"
|
34
|
+
m.migration_template "db/migrate/create_permissions.rb", "db/migrate", :migration_file_name => "create_permissions"
|
35
|
+
m.migration_template "db/migrate/create_base_user_groups.rb", "db/migrate", :migration_file_name => "create_base_user_groups"
|
36
|
+
|
37
|
+
#Route file (i like having them on individual lines)
|
38
|
+
m.route_resources "permissions"
|
39
|
+
m.route_resources "user_groups"
|
40
|
+
m.route_resources "users"
|
41
|
+
m.route_resources "sessions"
|
36
42
|
|
37
43
|
#Helpers
|
38
44
|
m.file "app/helpers/permissions_helper.rb", "app/helpers/permissions_helper.rb"
|
@@ -45,7 +51,9 @@ class LockdownAllGenerator < RubiGen::Base
|
|
45
51
|
|
46
52
|
copy_views(m, "user_groups")
|
47
53
|
|
48
|
-
|
54
|
+
m.file "app/views/permissions/_data.html.erb", "app/views/permissions/_data.html.erb"
|
55
|
+
m.file "app/views/permissions/index.html.erb", "app/views/permissions/index.html.erb"
|
56
|
+
m.file "app/views/permissions/show.html.erb", "app/views/permissions/show.html.erb"
|
49
57
|
|
50
58
|
m.file "app/views/sessions/new.html.erb", "app/views/sessions/new.html.erb"
|
51
59
|
end
|
@@ -54,9 +62,10 @@ class LockdownAllGenerator < RubiGen::Base
|
|
54
62
|
protected
|
55
63
|
def banner
|
56
64
|
<<-EOS
|
57
|
-
|
65
|
+
Installs the lockdown framework to managing users user_groups and viewing permissions.
|
66
|
+
Also includes a login screen.
|
58
67
|
|
59
|
-
USAGE: #{$0} #{spec.name}
|
68
|
+
USAGE: #{$0} #{spec.name}
|
60
69
|
EOS
|
61
70
|
end
|
62
71
|
|
@@ -5,8 +5,6 @@ class UsersController < ApplicationController
|
|
5
5
|
# GET /users.xml
|
6
6
|
def index
|
7
7
|
@users = User.all
|
8
|
-
logger.info "===============> access rights: #{session[:access_rights].join("\n")}" unless session[:access_rights] == :all
|
9
|
-
logger.info "===============> is: #{current_user_is_admin?}"
|
10
8
|
respond_to do |format|
|
11
9
|
format.html # index.html.erb
|
12
10
|
format.xml { render :xml => @users }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Profile < ActiveRecord::Base
|
2
|
+
SYSTEM = 1
|
3
|
+
|
4
|
+
validates_presence_of :email, :first_name, :last_name
|
5
|
+
|
6
|
+
validates_length_of :email, :within => 5..100
|
7
|
+
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
8
|
+
|
9
|
+
validates_uniqueness_of :email, :case_sensitive => false
|
10
|
+
end
|
@@ -95,6 +95,8 @@ class UserGroup < ActiveRecord::Base
|
|
95
95
|
# to errors by mistakingly removing them.
|
96
96
|
#
|
97
97
|
def find_assignable_for_user(usr)
|
98
|
+
return [] if usr.nil?
|
99
|
+
|
98
100
|
if usr.administrator?
|
99
101
|
find :all,
|
100
102
|
:conditions => "name != 'Public Access' and name != 'Registered Users'",
|
@@ -121,6 +123,8 @@ class UserGroup < ActiveRecord::Base
|
|
121
123
|
#
|
122
124
|
#
|
123
125
|
def find_content_assignable_for_user(usr)
|
126
|
+
return [] if usr.nil?
|
127
|
+
|
124
128
|
if usr.administrator?
|
125
129
|
find :all
|
126
130
|
else
|
@@ -5,11 +5,15 @@ class CreatePermissions < ActiveRecord::Migration
|
|
5
5
|
|
6
6
|
t.timestamps
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
|
+
create_table :permissions_user_groups, :id => false do |t|
|
10
|
+
t.integer :permission_id
|
11
|
+
t.integer :user_group_id
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.down
|
12
|
-
|
16
|
+
drop_table :permissions_user_groups
|
13
17
|
drop_table :permissions
|
14
18
|
end
|
15
19
|
end
|
@@ -5,11 +5,15 @@ class CreateUserGroups < ActiveRecord::Migration
|
|
5
5
|
|
6
6
|
t.timestamps
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
|
+
create_table :user_groups_users, :id => false do |t|
|
10
|
+
t.integer :user_group_id
|
11
|
+
t.integer :user_id
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.down
|
12
|
-
|
16
|
+
drop_table :user_groups_users
|
13
17
|
drop_table :user_groups
|
14
18
|
end
|
15
19
|
end
|
@@ -4,17 +4,14 @@ class CreateUsers < ActiveRecord::Migration
|
|
4
4
|
t.string :login
|
5
5
|
t.string :crypted_password
|
6
6
|
t.string :salt
|
7
|
+
t.integer :profile_id
|
7
8
|
t.integer :updated_by
|
8
9
|
|
9
10
|
t.timestamps
|
10
11
|
end
|
11
|
-
add_foreign_key :users, :profiles
|
12
|
-
define_foreign_key_column :users, :updated_by, :profiles
|
13
12
|
end
|
14
13
|
|
15
14
|
def self.down
|
16
|
-
remove_foreign_key :users, :profiles
|
17
|
-
remove_foreign_key_column :users, :updated_by
|
18
15
|
drop_table :users
|
19
16
|
end
|
20
17
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>lockdown</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.2.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘lockdown’</h1>
|
39
39
|
|
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
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Stone
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb
|
69
69
|
- rails_generators/lockdown_all/templates/app/helpers/users_helper.rb
|
70
70
|
- rails_generators/lockdown_all/templates/app/models/permission.rb
|
71
|
+
- rails_generators/lockdown_all/templates/app/models/profile.rb
|
71
72
|
- rails_generators/lockdown_all/templates/app/models/user.rb
|
72
73
|
- rails_generators/lockdown_all/templates/app/models/user_group.rb
|
73
74
|
- rails_generators/lockdown_all/templates/app/views/permissions/_data.html.erb
|
@@ -87,8 +88,9 @@ files:
|
|
87
88
|
- rails_generators/lockdown_all/templates/app/views/users/index.html.erb
|
88
89
|
- rails_generators/lockdown_all/templates/app/views/users/new.html.erb
|
89
90
|
- rails_generators/lockdown_all/templates/app/views/users/show.html.erb
|
91
|
+
- rails_generators/lockdown_all/templates/db/migrate/create_base_user_groups.rb
|
90
92
|
- rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb
|
91
|
-
- rails_generators/lockdown_all/templates/db/migrate/
|
93
|
+
- rails_generators/lockdown_all/templates/db/migrate/create_profiles.rb
|
92
94
|
- rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb
|
93
95
|
- rails_generators/lockdown_all/templates/db/migrate/create_users.rb
|
94
96
|
- script/console
|