effective_roles 0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/README.md +203 -14
- data/app/helpers/effective_roles_helper.rb +6 -6
- data/app/models/concerns/acts_as_role_restricted.rb +13 -6
- data/app/views/effective/roles/_roles_fields.html.haml +2 -2
- data/lib/effective_roles.rb +24 -0
- data/lib/effective_roles/version.rb +1 -1
- data/lib/generators/templates/effective_roles.rb +49 -21
- metadata +27 -111
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9df4ba4a70253bd8bef9933d1cdb8baf69ac87d8
|
4
|
+
data.tar.gz: f0dca667a92690beaaf43b2e1be460ce787374d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19340a70b419ce8f90babe9577b8dcb86b2402c34c9590245999a9d2dd00aec25c7fba4c9cfa30cd6334ec3da04c399af0ff53e7e1e2d64de0d82e5dc52823f3
|
7
|
+
data.tar.gz: 37f593b0331836a0119b878c8494737d46bf002531f5fd6eaf6eb4d0b56345685dfe91039e5577db88651cff54cdd011c4f319b1c7442cb886c61c23bb5d8236
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# Effective Roles
|
2
2
|
|
3
|
+
Assign multiple roles to any User or other ActiveRecord object. Select only the appropriate objects based on intelligent, chainable ActiveRecord::Relation finder methods.
|
4
|
+
|
3
5
|
Implements multi-role authorization based on an integer roles_mask field
|
4
6
|
|
5
7
|
Includes a mixin for adding authentication for any model.
|
6
8
|
|
7
|
-
SQL Finders for returning
|
8
|
-
|
9
|
-
Handy formtastic helper for assigning roles.
|
10
|
-
|
11
|
-
Intended for use with the other effective_* gems
|
9
|
+
SQL Finders for returning an ActiveRecord::Relation with all permitted records.
|
12
10
|
|
13
|
-
|
11
|
+
Handy formtastic and simple_form helpers for assigning roles.
|
14
12
|
|
15
|
-
Rails
|
13
|
+
Rails 3.2.x and Rails 4
|
16
14
|
|
17
15
|
|
18
16
|
## Getting Started
|
@@ -47,7 +45,7 @@ class Post
|
|
47
45
|
end
|
48
46
|
```
|
49
47
|
|
50
|
-
Then create a migration to add the :
|
48
|
+
Then create a migration to add the :roles_mask column to the model.
|
51
49
|
|
52
50
|
```console
|
53
51
|
rails generate migration add_roles_to_post roles_mask:integer
|
@@ -63,11 +61,22 @@ class AddRolesToPost < ActiveRecord::Migration
|
|
63
61
|
end
|
64
62
|
```
|
65
63
|
|
66
|
-
##
|
64
|
+
## Strong Parameters
|
65
|
+
|
66
|
+
Make your controller aware of the acts_as_role_restricted passed parameters:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
def permitted_params
|
70
|
+
params.require(:base_object).permit(:roles => [])
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
|
75
|
+
## Usage
|
67
76
|
|
68
77
|
### Defining Roles
|
69
78
|
|
70
|
-
All roles are defined in the config/effective_roles.rb initializer.
|
79
|
+
All roles are defined in the config/effective_roles.rb initializer. The roles are defined once and may be applied to any acts_as_role_restricted model in the application.
|
71
80
|
|
72
81
|
### Model
|
73
82
|
|
@@ -91,12 +100,51 @@ post.roles
|
|
91
100
|
=> [:admin, :superadmin]
|
92
101
|
```
|
93
102
|
|
103
|
+
Compare against another acts_as_role_restricted object:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
user = User.new()
|
107
|
+
user.roles = []
|
108
|
+
|
109
|
+
post = Post.new()
|
110
|
+
post.roles = [:admin]
|
111
|
+
|
112
|
+
user.roles_match_with?(post)
|
113
|
+
=> false # User has no roles, but Post requires :admin
|
114
|
+
|
115
|
+
post.roles_match_with?(user)
|
116
|
+
=> true # Post has the role of :admin, but User requires no roles
|
117
|
+
```
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
user.roles = [:admin]
|
121
|
+
post.roles = [:superadmin]
|
122
|
+
|
123
|
+
user.roles_match_with?(post)
|
124
|
+
=> false # User does not have the superadmin role
|
125
|
+
|
126
|
+
post.roles_match_with?(user)
|
127
|
+
=> false # Post does not have the admin role
|
128
|
+
```
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
user.roles = [:superadmin, :admin]
|
132
|
+
post.roles = [:admin]
|
133
|
+
|
134
|
+
user.roles_match_with?(post)
|
135
|
+
=> true # User has :admin and so does Post
|
136
|
+
|
137
|
+
post.roles_match_with?(user)
|
138
|
+
=> true # Post has :admin and so does User
|
139
|
+
```
|
140
|
+
|
94
141
|
### Finder Methods
|
95
142
|
|
96
|
-
Find all objects that have been assigned a specific role (or roles). Will not return posts that have no assigned roles (roles_mask = 0)
|
143
|
+
Find all objects that have been assigned a specific role (or roles). Will not return posts that have no assigned roles (roles_mask = 0 or NULL)
|
97
144
|
|
98
145
|
```ruby
|
99
146
|
Post.with_role(:admin, :superadmin) # Can pass as an array if you want
|
147
|
+
Post.with_role(current_user.roles)
|
100
148
|
```
|
101
149
|
|
102
150
|
Find all objects that are appropriate for a specific role. Will return posts that have no assigned roles
|
@@ -108,17 +156,146 @@ Post.for_role(current_user.roles)
|
|
108
156
|
|
109
157
|
These are both ActiveRecord::Relations, so you can chain them with other methods like normal.
|
110
158
|
|
159
|
+
## Assignable Roles
|
160
|
+
|
161
|
+
Specifies which roles can be assigned to a resource by a specific user.
|
162
|
+
|
163
|
+
See the initializers/effective_roles.rb for more information.
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
config.assignable_roles = {
|
167
|
+
:superadmin => [:superadmin, :admin, :member], # Superadmins may assign any resource any role
|
168
|
+
:admin => [:admin, :member], # Admins may only assign the :admin or :member role
|
169
|
+
:member => [] # Members may not assign any roles
|
170
|
+
}
|
171
|
+
```
|
172
|
+
|
173
|
+
When used in a Form Helper (see below), only the appropriate roles will be displayed.
|
174
|
+
|
175
|
+
However, this restriction is not enforced on the controller level, so someone could inspect & re-write the form parameters and still assign a role that they are not allowed to.
|
176
|
+
|
177
|
+
To prevent this, add something like the following code to your controller:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
before_filter :only => [:create, :update] do
|
181
|
+
if params[:user] && params[:user][:roles]
|
182
|
+
params[:user][:roles] = params[:user][:roles] & EffectiveRoles.assignable_roles_for(current_user, User.new()).map(&:to_s)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
```
|
186
|
+
|
187
|
+
|
188
|
+
## Form Helper
|
189
|
+
|
190
|
+
If you pass current_user (or any acts_as_role_restricted object) into these helpers, only the assignable_roles will be displayed.
|
191
|
+
|
192
|
+
### Formtastic
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
semantic_form_for @user do |f|
|
196
|
+
= effective_roles_fields(f)
|
197
|
+
```
|
198
|
+
|
199
|
+
or
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
semantic_form_for @user do |f|
|
203
|
+
= effective_roles_fields(f, current_user)
|
204
|
+
```
|
205
|
+
|
206
|
+
### simple_form
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
simple_form_for @user do |f|
|
210
|
+
= f.input :roles, :collection => EffectiveRoles.roles_collection(f.object), :as => :check_boxes
|
211
|
+
```
|
212
|
+
|
213
|
+
or
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
simple_form_for @user do |f|
|
217
|
+
= f.input :roles, :collection => EffectiveRoles.roles_collection(f.object, current_user), :as => :check_boxes
|
218
|
+
```
|
219
|
+
|
220
|
+
## Bitmask Implementation
|
221
|
+
|
222
|
+
The underlying role information for any acts_as_role_restricted ActiveRecord object is stored in that object's roles_mask field.
|
223
|
+
|
224
|
+
roles_mask is an integer, in which each power of 2 represents the presence or absense of a role.
|
225
|
+
|
226
|
+
If we have the following roles defined:
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
EffectiveRoles.setup do |config|
|
230
|
+
config.roles = [:superadmin, :admin, :betauser, :member]
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
Then the following will hold true:
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
user = User.new()
|
238
|
+
|
239
|
+
user.roles
|
240
|
+
=> []
|
241
|
+
|
242
|
+
user.roles_mask
|
243
|
+
=> 0
|
244
|
+
|
245
|
+
user.roles = [:superadmin]
|
246
|
+
user.roles_mask
|
247
|
+
=> 1
|
248
|
+
|
249
|
+
user.roles = [:admin]
|
250
|
+
user.roles_mask
|
251
|
+
=> 2
|
252
|
+
|
253
|
+
user.roles = [:betauser]
|
254
|
+
user.roles_mask
|
255
|
+
=> 4
|
256
|
+
|
257
|
+
user.roles = [:member]
|
258
|
+
user.roles_mask
|
259
|
+
=> 8
|
260
|
+
```
|
261
|
+
|
262
|
+
As well:
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
user.roles = [:superadmin, :admin]
|
266
|
+
user.roles_mask
|
267
|
+
=> 3
|
268
|
+
|
269
|
+
user.roles = [:superadmin, :betauser]
|
270
|
+
user.roles_mask
|
271
|
+
=> 5
|
272
|
+
|
273
|
+
user.roles = [:admin, :member]
|
274
|
+
user.roles_mask
|
275
|
+
=> 10
|
276
|
+
|
277
|
+
user.roles = [:superadmin, :admin, :betauser, :member]
|
278
|
+
user.roles_mask
|
279
|
+
=> 15
|
280
|
+
```
|
281
|
+
|
282
|
+
Keep in mind, when using this gem you should never be working directly with the roles_mask field.
|
283
|
+
|
284
|
+
All roles are get/set through the roles and roles= methods.
|
285
|
+
|
286
|
+
|
111
287
|
## License
|
112
288
|
|
113
|
-
MIT License. Copyright Code and Effect Inc.
|
289
|
+
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
290
|
+
|
291
|
+
Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/), an Edmonton-based shop that specializes in building custom web applications with Ruby on Rails.
|
114
292
|
|
115
|
-
You are not granted rights or licenses to the trademarks of Code and Effect
|
116
293
|
|
117
294
|
## Credits
|
118
295
|
|
119
296
|
This model implements the https://github.com/ryanb/cancan/wiki/Role-Based-Authorization multi role based authorization based on the roles_mask field
|
120
297
|
|
121
|
-
|
298
|
+
## Testing
|
122
299
|
|
123
300
|
The test suite for this gem is unfortunately not yet complete.
|
124
301
|
|
@@ -127,3 +304,15 @@ Run tests by:
|
|
127
304
|
```ruby
|
128
305
|
rake spec
|
129
306
|
```
|
307
|
+
|
308
|
+
|
309
|
+
## Contributing
|
310
|
+
|
311
|
+
1. Fork it
|
312
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
313
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
314
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
315
|
+
5. Bonus points for test coverage
|
316
|
+
6. Create new Pull Request
|
317
|
+
|
318
|
+
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module EffectiveRolesHelper
|
2
2
|
# For use in formtastic forms
|
3
|
-
def effective_roles_fields(form, options = {})
|
4
|
-
|
5
|
-
role_descriptions = EffectiveRoles.role_descriptions[form.object.class.name]
|
6
|
-
end
|
7
|
-
role_descriptions ||= (EffectiveRoles.role_descriptions || [])
|
3
|
+
def effective_roles_fields(form, user = nil, options = {})
|
4
|
+
raise ArgumentError.new('EffectiveRoles config.role_descriptions must be a Hash. The Array syntax is deprecated.') unless EffectiveRoles.role_descriptions.kind_of?(Hash)
|
8
5
|
|
9
|
-
|
6
|
+
roles = EffectiveRoles.assignable_roles_for(user, form.object)
|
7
|
+
descriptions = EffectiveRoles.role_descriptions[form.object.class.name] || EffectiveRoles.role_descriptions || {}
|
8
|
+
|
9
|
+
opts = {:f => form, :roles => roles, :descriptions => descriptions}.merge(options)
|
10
10
|
|
11
11
|
render :partial => 'effective/roles/roles_fields', :locals => opts
|
12
12
|
end
|
@@ -45,9 +45,20 @@ module ActsAsRoleRestricted
|
|
45
45
|
|
46
46
|
def with_role_sql(*roles)
|
47
47
|
roles = roles.flatten.compact
|
48
|
+
roles = roles.first.try(:roles) if roles.length == 1 and roles.first.respond_to?(:roles)
|
49
|
+
|
48
50
|
roles = (roles.map { |role| role.to_sym } & EffectiveRoles.roles)
|
49
51
|
roles.map { |role| "(#{self.table_name}.roles_mask & %d > 0)" % 2**EffectiveRoles.roles.index(role) }.join(' OR ')
|
50
52
|
end
|
53
|
+
|
54
|
+
def without_role(*roles)
|
55
|
+
roles = roles.flatten.compact
|
56
|
+
roles = roles.first.try(:roles) if roles.length == 1 and roles.first.respond_to?(:roles)
|
57
|
+
|
58
|
+
roles = (roles.map { |role| role.to_sym } & EffectiveRoles.roles)
|
59
|
+
|
60
|
+
where(roles.map { |role| "NOT(#{self.table_name}.roles_mask & %d > 0)" % 2**EffectiveRoles.roles.index(role) }.join(' OR '))
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
64
|
def roles=(roles)
|
@@ -64,11 +75,7 @@ module ActsAsRoleRestricted
|
|
64
75
|
end
|
65
76
|
|
66
77
|
def roles_match_with?(obj)
|
67
|
-
if is_role_restricted?
|
68
|
-
true
|
69
|
-
elsif obj.respond_to?(:is_role_restricted?) == false
|
70
|
-
false
|
71
|
-
elsif obj.is_role_restricted? == false
|
78
|
+
if !obj.respond_to?(:is_role_restricted?) || !obj.is_role_restricted?
|
72
79
|
true
|
73
80
|
else
|
74
81
|
(roles & obj.roles).any?
|
@@ -76,7 +83,7 @@ module ActsAsRoleRestricted
|
|
76
83
|
end
|
77
84
|
|
78
85
|
def is_role_restricted?
|
79
|
-
roles_mask > 0
|
86
|
+
(roles_mask || 0) > 0
|
80
87
|
end
|
81
88
|
end
|
82
89
|
|
@@ -10,8 +10,8 @@
|
|
10
10
|
%label Roles
|
11
11
|
%input{:type => :hidden, :id => "#{obj}_roles_none", :name => "#{obj}[roles][]"}
|
12
12
|
%ol.choices-group
|
13
|
-
-
|
13
|
+
- roles.each do |role|
|
14
14
|
%li.choice
|
15
15
|
%label{:for => "#{obj}_roles_#{role}"}
|
16
16
|
%input{:type => :checkbox, :id => "#{obj}_roles_#{role}", :name => "#{obj}[roles][]", :value => role.to_s, :checked => ("checked" if f.object.roles.include?(role))}= role
|
17
|
-
%p.inline-hints{:style => "margin: 2px 0 16px 0;"}=
|
17
|
+
%p.inline-hints{:style => "margin: 2px 0 16px 0;"}= descriptions[role]
|
data/lib/effective_roles.rb
CHANGED
@@ -3,10 +3,34 @@ require "effective_roles/version"
|
|
3
3
|
|
4
4
|
module EffectiveRoles
|
5
5
|
mattr_accessor :roles
|
6
|
+
mattr_accessor :assignable_roles
|
6
7
|
mattr_accessor :role_descriptions
|
7
8
|
|
8
9
|
def self.setup
|
9
10
|
yield self
|
10
11
|
end
|
11
12
|
|
13
|
+
def self.roles_collection(obj = nil, user = nil)
|
14
|
+
raise ArgumentError.new('EffectiveRoles config.role_descriptions must be a Hash. The Array syntax is deprecated.') unless EffectiveRoles.role_descriptions.kind_of?(Hash)
|
15
|
+
|
16
|
+
descriptions = role_descriptions[obj.try(:class).to_s] || role_descriptions || {}
|
17
|
+
|
18
|
+
assignable_roles_for(user, obj).map do |role|
|
19
|
+
["#{role}<br>#{descriptions[role]}".html_safe, role]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.assignable_roles_for(user, obj = nil)
|
24
|
+
return roles unless user.respond_to?(:is_role_restricted?) # All roles, if the user (or object) is not role_resticted
|
25
|
+
|
26
|
+
assignable = assignable_roles[obj.try(:class).to_s] || assignable_roles || {}
|
27
|
+
|
28
|
+
if assignable.present?
|
29
|
+
user.roles.map { |role| assignable[role] }.flatten.compact.uniq
|
30
|
+
else
|
31
|
+
roles
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
12
36
|
end
|
@@ -1,30 +1,58 @@
|
|
1
1
|
EffectiveRoles.setup do |config|
|
2
2
|
config.roles = [:superadmin, :admin, :member] # Only add to the end of this array. Never prepend roles.
|
3
3
|
|
4
|
-
# config.
|
5
|
-
#
|
6
|
-
|
7
|
-
#
|
4
|
+
# config.assignable_roles
|
5
|
+
# =======================
|
6
|
+
# When current_user is passed into a form helper function (see README.md)
|
7
|
+
# this setting determines which roles that current_user may assign
|
8
|
+
#
|
9
|
+
# Use this Hash syntax if you want different permissions depending on the resource being editted
|
10
|
+
#
|
11
|
+
# config.assignable_roles = {
|
12
|
+
# 'User' => {
|
13
|
+
# :superadmin => [:superadmin, :admin, :member], # Superadmins may assign Users any role
|
14
|
+
# :admin => [:admin, :member], # Admins may only assign a User the :admin or :member role
|
15
|
+
# :member => [] # Members may not assign any roles
|
16
|
+
# },
|
17
|
+
# 'Page' => {
|
18
|
+
# :superadmin => [:superadmin, :admin, :member], # Superadmins may create Pages for any role
|
19
|
+
# :admin => [:admin, :member], # Admins may create Pages for admin and members
|
20
|
+
# :member => [:member] # Members may create Pages for members
|
21
|
+
# }
|
8
22
|
#
|
23
|
+
# Or just keep it simple, and use this Hash syntax of permissions for every resource
|
24
|
+
#
|
25
|
+
config.assignable_roles = {
|
26
|
+
:superadmin => [:superadmin, :admin, :member], # Superadmins may assign any resource any role
|
27
|
+
:admin => [:admin, :member], # Admins may only assign the :admin or :member role
|
28
|
+
:member => [] # Members may not assign any roles
|
29
|
+
}
|
9
30
|
|
31
|
+
# config.role_descriptions
|
32
|
+
# ========================
|
33
|
+
# This setting configures the text that is displayed by form helpers (see README.md)
|
34
|
+
#
|
35
|
+
# Use this Hash syntax if you want different labels depending on the resource being editted
|
36
|
+
#
|
10
37
|
# config.role_descriptions = {
|
11
|
-
# 'User' =>
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# 'Effective::Page' =>
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
38
|
+
# 'User' => {
|
39
|
+
# :superadmin => 'full access to everything. Can manage users and all website content.',
|
40
|
+
# :admin => 'full access to website content. Cannot manage users.',
|
41
|
+
# :member => 'cannot access admin area. Can see all content in members-only sections of the website.''
|
42
|
+
# },
|
43
|
+
# 'Effective::Page' => {
|
44
|
+
# :superadmin => 'allow superadmins to see this page',
|
45
|
+
# :admin => 'allow admins to see this page',
|
46
|
+
# :member => 'allow members to see this page'
|
47
|
+
# }
|
21
48
|
# }
|
22
|
-
|
23
|
-
# Or just keep it simple, and use the same Array of labels for everything
|
24
49
|
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
50
|
+
# Or just keep it simple, and use this Hash syntax of permissions for every resource
|
51
|
+
#
|
52
|
+
config.role_descriptions = {
|
53
|
+
:superadmin => 'full access to everything. Can manage users and all website content.',
|
54
|
+
:admin => 'full access to website content. Cannot manage users.',
|
55
|
+
:member => 'cannot access admin area. Can see all content in members-only sections of the website.'
|
56
|
+
}
|
57
|
+
|
30
58
|
end
|
metadata
CHANGED
@@ -1,141 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_roles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Code and Effect
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 3.2.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec-rails
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: shoulda-matchers
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: sqlite3
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: psych
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
description: Implements multi-role authorization based on an integer roles_mask field.
|
111
|
-
Includes a mixin for adding authentication for any model. SQL Finders for returning
|
112
|
-
a Relation with all permitted records. Handy formtastic helper for assigning roles.
|
113
|
-
Intended for use with the other effective_* gems Designed to work on its own, or
|
114
|
-
with simple pass through to CanCan
|
26
|
+
version: 3.2.0
|
27
|
+
description: Assign multiple roles to any User or other ActiveRecord object. Select
|
28
|
+
only the appropriate objects based on intelligent, chainable ActiveRecord::Relation
|
29
|
+
finder methods.
|
115
30
|
email:
|
116
31
|
- info@codeandeffect.com
|
117
32
|
executables: []
|
118
33
|
extensions: []
|
119
34
|
extra_rdoc_files: []
|
120
35
|
files:
|
36
|
+
- MIT-LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
121
39
|
- app/helpers/effective_roles_helper.rb
|
122
40
|
- app/models/concerns/acts_as_role_restricted.rb
|
123
41
|
- app/views/effective/roles/_roles_fields.html.haml
|
42
|
+
- lib/effective_roles.rb
|
124
43
|
- lib/effective_roles/engine.rb
|
125
44
|
- lib/effective_roles/version.rb
|
126
|
-
- lib/effective_roles.rb
|
127
45
|
- lib/generators/effective_roles/install_generator.rb
|
128
|
-
- lib/generators/templates/effective_roles.rb
|
129
46
|
- lib/generators/templates/README
|
47
|
+
- lib/generators/templates/effective_roles.rb
|
130
48
|
- lib/tasks/effective_roles_tasks.rake
|
131
|
-
-
|
132
|
-
- Rakefile
|
133
|
-
- README.md
|
49
|
+
- spec/dummy/README.rdoc
|
50
|
+
- spec/dummy/Rakefile
|
134
51
|
- spec/dummy/app/assets/javascripts/application.js
|
135
52
|
- spec/dummy/app/assets/stylesheets/application.css
|
136
53
|
- spec/dummy/app/controllers/application_controller.rb
|
137
54
|
- spec/dummy/app/helpers/application_helper.rb
|
138
55
|
- spec/dummy/app/views/layouts/application.html.erb
|
56
|
+
- spec/dummy/config.ru
|
139
57
|
- spec/dummy/config/application.rb
|
140
58
|
- spec/dummy/config/boot.rb
|
141
59
|
- spec/dummy/config/database.yml
|
@@ -151,7 +69,6 @@ files:
|
|
151
69
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
152
70
|
- spec/dummy/config/locales/en.yml
|
153
71
|
- spec/dummy/config/routes.rb
|
154
|
-
- spec/dummy/config.ru
|
155
72
|
- spec/dummy/db/development.sqlite3
|
156
73
|
- spec/dummy/db/schema.rb
|
157
74
|
- spec/dummy/db/test.sqlite3
|
@@ -161,36 +78,36 @@ files:
|
|
161
78
|
- spec/dummy/public/422.html
|
162
79
|
- spec/dummy/public/500.html
|
163
80
|
- spec/dummy/public/favicon.ico
|
164
|
-
- spec/dummy/Rakefile
|
165
|
-
- spec/dummy/README.rdoc
|
166
81
|
- spec/dummy/script/rails
|
167
82
|
- spec/effective_roles_spec.rb
|
168
83
|
- spec/spec_helper.rb
|
169
84
|
- spec/support/factories.rb
|
170
85
|
homepage: https://github.com/code-and-effect/effective_roles
|
171
|
-
licenses:
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
172
89
|
post_install_message:
|
173
90
|
rdoc_options: []
|
174
91
|
require_paths:
|
175
92
|
- lib
|
176
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
94
|
requirements:
|
179
|
-
- -
|
95
|
+
- - ">="
|
180
96
|
- !ruby/object:Gem::Version
|
181
97
|
version: '0'
|
182
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
-
none: false
|
184
99
|
requirements:
|
185
|
-
- -
|
100
|
+
- - ">="
|
186
101
|
- !ruby/object:Gem::Version
|
187
102
|
version: '0'
|
188
103
|
requirements: []
|
189
104
|
rubyforge_project:
|
190
|
-
rubygems_version:
|
105
|
+
rubygems_version: 2.4.3
|
191
106
|
signing_key:
|
192
|
-
specification_version:
|
193
|
-
summary:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Assign multiple roles to any User or other ActiveRecord object. Select only
|
109
|
+
the appropriate objects based on intelligent, chainable ActiveRecord::Relation finder
|
110
|
+
methods.
|
194
111
|
test_files:
|
195
112
|
- spec/dummy/app/assets/javascripts/application.js
|
196
113
|
- spec/dummy/app/assets/stylesheets/application.css
|
@@ -228,4 +145,3 @@ test_files:
|
|
228
145
|
- spec/effective_roles_spec.rb
|
229
146
|
- spec/spec_helper.rb
|
230
147
|
- spec/support/factories.rb
|
231
|
-
has_rdoc:
|