lockdown 0.3.5 → 0.3.6
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.
- data/History.txt +3 -0
- data/app_generators/lockdown/templates/init.rb +1 -1
- data/lib/lockdown/version.rb +1 -1
- data/website/index.txt +77 -106
- metadata +1 -1
data/History.txt
CHANGED
data/lib/lockdown/version.rb
CHANGED
data/website/index.txt
CHANGED
@@ -52,117 +52,88 @@ The above list will be stored in the session as an array and each request is tes
|
|
52
52
|
|
53
53
|
To define access rights you need to modify lib/lockdown/init.rb. This is the default init.rb included with Lockdown:
|
54
54
|
<pre syntax="ruby">
|
55
|
-
|
55
|
+
require "lockdown"
|
56
|
+
require File.join(File.dirname(__FILE__), "session")
|
56
57
|
|
57
|
-
|
58
|
+
Lockdown::System.configure do
|
59
|
+
|
60
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
61
|
+
# Configuration Options
|
62
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
63
|
+
# Options with defaults:
|
64
|
+
#
|
65
|
+
# Set timeout to 1 hour:
|
66
|
+
# options[:session_timeout] = (60 * 60)
|
67
|
+
#
|
68
|
+
# Set system to logout if unauthorized access is attempted:
|
69
|
+
# options[:logout_on_access_violation] = false
|
70
|
+
#
|
71
|
+
# Set redirect to path on unauthorized access attempt:
|
72
|
+
# options[:access_denied_path] = "/"
|
73
|
+
#
|
74
|
+
# Set redirect to path on successful login:
|
75
|
+
# options[:successful_login_path] = "/"
|
76
|
+
#
|
77
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
78
|
+
# Define permissions
|
79
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
80
|
+
#
|
81
|
+
# set_permission(:product_management, all_methods(:products))
|
82
|
+
#
|
83
|
+
# :product_management is the name of the permission which is later
|
84
|
+
# referenced by the set_user_group method
|
85
|
+
#
|
86
|
+
# :all_methods(:products) will return an array of all controller actions
|
87
|
+
# for the products controller
|
88
|
+
#
|
89
|
+
# if products is your standard RESTful resource you'll get:
|
90
|
+
# ["products/index , "products/show",
|
91
|
+
# "products/new", "products/edit",
|
92
|
+
# "products/create", "products/update",
|
93
|
+
# "products/destroy"]
|
58
94
|
#
|
95
|
+
# You can pass multiple parameters to concat permissions such as:
|
96
|
+
#
|
97
|
+
# set_permission(:security_management,all_methods(:users),
|
98
|
+
# all_methods(:user_groups),
|
99
|
+
# all_methods(:permissions) )
|
59
100
|
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
101
|
+
# In addition to all_methods(:controller) there are:
|
102
|
+
#
|
103
|
+
# only_methods(:controller, :only_method_1, :only_method_2)
|
104
|
+
#
|
105
|
+
# all_except_methods(:controller, :except_method_1, :except_method_2)
|
106
|
+
#
|
107
|
+
# Some other sample permissions:
|
63
108
|
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
# # Returns all methods from all controllers
|
67
|
-
# all_controllers
|
68
|
-
#
|
69
|
-
# # Returns all methods from all controllers listed
|
70
|
-
# all_methods :controller1, controller2, ...
|
71
|
-
#
|
72
|
-
# # For a single controller, returns only methods listed
|
73
|
-
# only_methods :controller1, :method1, :method2, ...
|
74
|
-
#
|
75
|
-
# # For a single controller, returns all methods except the methods listed
|
76
|
-
# all_except_methods :controller1, :method1, :method2, ...
|
77
|
-
#
|
78
|
-
# They all return an array of controller/action. For example, if you had a
|
79
|
-
# standard REST controller called products this would be the result:
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# all_methods :products => [ "products/index , "products/show",
|
83
|
-
# "products/new", "products/edit",
|
84
|
-
# "products/create", "products/update",
|
85
|
-
# "products/destroy"]
|
86
|
-
#
|
87
|
-
module Permissions
|
88
|
-
class << self
|
89
|
-
|
90
|
-
def sessions_management
|
91
|
-
# all_methods :sessions
|
92
|
-
end
|
93
|
-
|
94
|
-
end # end class block
|
95
|
-
end # end Permissions module
|
96
|
-
|
97
|
-
#
|
98
|
-
# UserGroups are used to group Permissions together to define role type
|
99
|
-
# functionality. Users may belong to multiple groups.
|
109
|
+
# set_permission(:sessions, all_methods(:sessions))
|
110
|
+
# set_permission(:my_account, only_methods(:users, :edit, :update, :show))
|
100
111
|
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
# Standard administrator user group.
|
127
|
-
# Please don't alter without careful consideration.
|
128
|
-
#
|
129
|
-
def administrators
|
130
|
-
[:all]
|
131
|
-
end
|
132
|
-
|
133
|
-
# ** The public_access method is "special", please don't rename.
|
134
|
-
# If you remove/rename, etc... YOU WILL BREAK STUFF
|
135
|
-
#
|
136
|
-
# Standard public_access user group.
|
137
|
-
#
|
138
|
-
# Feel free to add Permissions to the array without issue.
|
139
|
-
#
|
140
|
-
# **Notice: All permissions added to this public_access group will not be
|
141
|
-
# restricted to logged in users.
|
142
|
-
# So be careful what you add here!
|
143
|
-
#
|
144
|
-
def public_access
|
145
|
-
[:sessions_management]
|
146
|
-
end
|
147
|
-
|
148
|
-
# ** The registered_users method is "special", please don't rename.
|
149
|
-
# Not as special as the others, but still...
|
150
|
-
#
|
151
|
-
# All newly created users are assigned to this User Group by default
|
152
|
-
#
|
153
|
-
# Sample registered_users permission:
|
154
|
-
# [:my_account]
|
155
|
-
#
|
156
|
-
def registered_users
|
157
|
-
[]
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
# Define your own user groups below
|
162
|
-
#
|
163
|
-
end # end class block
|
164
|
-
end # end UserGroups module
|
165
|
-
end # end Lockdown module
|
112
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
113
|
+
# Built-in user groups
|
114
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
115
|
+
# You can assign the above permission to one of the built-in user groups
|
116
|
+
# by using the following:
|
117
|
+
#
|
118
|
+
# To allow public access on the permissions :sessions and :home:
|
119
|
+
# set_public_access :sessions, :home
|
120
|
+
#
|
121
|
+
# Restrict :my_account access to only authenticated users:
|
122
|
+
# set_protected_access :my_account
|
123
|
+
#
|
124
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
125
|
+
# Define user groups
|
126
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
127
|
+
#
|
128
|
+
# set_user_group(:catalog_management, :category_management,
|
129
|
+
# :product_management)
|
130
|
+
#
|
131
|
+
# :catalog_management is the name of the user group
|
132
|
+
# :category_management and :product_management refer to permission names
|
133
|
+
#
|
134
|
+
|
135
|
+
# Add your configuration below:
|
136
|
+
end
|
166
137
|
</pre>
|
167
138
|
|
168
139
|
|