dynamic_acl 0.1.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.
- checksums.yaml +7 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +99 -0
- data/LICENSE.txt +20 -0
- data/VERSION +1 -0
- data/app/controllers/dynamic_acls_controller.rb +30 -0
- data/dynamic_acl.gemspec +31 -0
- data/lib/dynamic_acl.rb +11 -0
- data/lib/dynamic_acl/engine.rb +8 -0
- data/lib/tasks/install.rake +36 -0
- metadata +54 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 729863941d5bdc0d82868d8ecb15a7dfe4c0697e
|
|
4
|
+
data.tar.gz: 587fca4ed0edef1f51f37e6924da8ddd277e8ce0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 880b4e6a2cebe1a6bed07dd789a02cc8243ec625fb263c5368fce7388c4a6a847e3cd618770d8f9744eaca561ddd036ab0e840e20b2a9bd0d8508cad27e1891f
|
|
7
|
+
data.tar.gz: 388288cda4524288e718692a0ae5acebf1b350ee6973c7cd745c9f65ed5b531d3c0a35ef294592ae8c589a1235e6ce1a622d344ad78f380e08eca0d17319dd41
|
data/Gemfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem 'railties'
|
|
4
|
+
gem "haml-rails", "~> 2.0"
|
|
5
|
+
|
|
6
|
+
group :development do
|
|
7
|
+
gem "rspec", '~> 2.10', '> 2.10.0'
|
|
8
|
+
gem "rdoc", '~> 4.0', '> 4.0.0'
|
|
9
|
+
gem "bundler", '~> 1.2', '> 1.2.0'
|
|
10
|
+
gem "jeweler", '~> 1.8', '> 1.8.4'
|
|
11
|
+
gem "simplecov",'~> 0.5'
|
|
12
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
abstract (1.0.0)
|
|
5
|
+
actionpack (3.0.8)
|
|
6
|
+
activemodel (= 3.0.8)
|
|
7
|
+
activesupport (= 3.0.8)
|
|
8
|
+
builder (~> 2.1.2)
|
|
9
|
+
erubis (~> 2.6.6)
|
|
10
|
+
i18n (~> 0.5.0)
|
|
11
|
+
rack (~> 1.2.1)
|
|
12
|
+
rack-mount (~> 0.6.14)
|
|
13
|
+
rack-test (~> 0.5.7)
|
|
14
|
+
tzinfo (~> 0.3.23)
|
|
15
|
+
activemodel (3.0.8)
|
|
16
|
+
activesupport (= 3.0.8)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
i18n (~> 0.5.0)
|
|
19
|
+
activesupport (3.0.8)
|
|
20
|
+
addressable (2.3.5)
|
|
21
|
+
builder (2.1.2)
|
|
22
|
+
diff-lcs (1.2.5)
|
|
23
|
+
erubis (2.6.6)
|
|
24
|
+
abstract (>= 1.0.0)
|
|
25
|
+
faraday (0.8.7)
|
|
26
|
+
multipart-post (~> 1.1)
|
|
27
|
+
git (1.2.5)
|
|
28
|
+
github_api (0.10.1)
|
|
29
|
+
addressable
|
|
30
|
+
faraday (~> 0.8.1)
|
|
31
|
+
hashie (>= 1.2)
|
|
32
|
+
multi_json (~> 1.4)
|
|
33
|
+
nokogiri (~> 1.5.2)
|
|
34
|
+
oauth2
|
|
35
|
+
hashie (2.0.5)
|
|
36
|
+
highline (1.6.19)
|
|
37
|
+
httpauth (0.2.0)
|
|
38
|
+
i18n (0.5.0)
|
|
39
|
+
jeweler (1.8.6)
|
|
40
|
+
builder
|
|
41
|
+
bundler (~> 1.0)
|
|
42
|
+
git (>= 1.2.5)
|
|
43
|
+
github_api (= 0.10.1)
|
|
44
|
+
highline (>= 1.6.15)
|
|
45
|
+
nokogiri (= 1.5.10)
|
|
46
|
+
rake
|
|
47
|
+
rdoc
|
|
48
|
+
json (1.8.1)
|
|
49
|
+
jwt (0.1.8)
|
|
50
|
+
multi_json (>= 1.5)
|
|
51
|
+
multi_json (1.10.1)
|
|
52
|
+
multi_xml (0.5.4)
|
|
53
|
+
multipart-post (1.2.0)
|
|
54
|
+
nokogiri (1.5.10)
|
|
55
|
+
oauth2 (0.9.2)
|
|
56
|
+
faraday (~> 0.8)
|
|
57
|
+
httpauth (~> 0.2)
|
|
58
|
+
jwt (~> 0.1.4)
|
|
59
|
+
multi_json (~> 1.0)
|
|
60
|
+
multi_xml (~> 0.5)
|
|
61
|
+
rack (~> 1.2)
|
|
62
|
+
rack (1.2.8)
|
|
63
|
+
rack-mount (0.6.14)
|
|
64
|
+
rack (>= 1.0.0)
|
|
65
|
+
rack-test (0.5.7)
|
|
66
|
+
rack (>= 1.0)
|
|
67
|
+
railties (3.0.8)
|
|
68
|
+
actionpack (= 3.0.8)
|
|
69
|
+
activesupport (= 3.0.8)
|
|
70
|
+
rake (>= 0.8.7)
|
|
71
|
+
thor (~> 0.14.4)
|
|
72
|
+
rake (10.1.1)
|
|
73
|
+
rdoc (4.1.2)
|
|
74
|
+
json (~> 1.4)
|
|
75
|
+
rspec (2.13.0)
|
|
76
|
+
rspec-core (~> 2.13.0)
|
|
77
|
+
rspec-expectations (~> 2.13.0)
|
|
78
|
+
rspec-mocks (~> 2.13.0)
|
|
79
|
+
rspec-core (2.13.1)
|
|
80
|
+
rspec-expectations (2.13.0)
|
|
81
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
82
|
+
rspec-mocks (2.13.0)
|
|
83
|
+
simplecov (0.7.1)
|
|
84
|
+
multi_json (~> 1.0)
|
|
85
|
+
simplecov-html (~> 0.7.1)
|
|
86
|
+
simplecov-html (0.7.1)
|
|
87
|
+
thor (0.14.6)
|
|
88
|
+
tzinfo (0.3.37)
|
|
89
|
+
|
|
90
|
+
PLATFORMS
|
|
91
|
+
ruby
|
|
92
|
+
|
|
93
|
+
DEPENDENCIES
|
|
94
|
+
bundler (~> 1.2, > 1.2.0)
|
|
95
|
+
jeweler (~> 1.8, > 1.8.4)
|
|
96
|
+
railties
|
|
97
|
+
rdoc (~> 4.0, > 4.0.0)
|
|
98
|
+
rspec (~> 2.10, > 2.10.0)
|
|
99
|
+
simplecov (~> 0.5)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012 Dileep Nandanam
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class DynamicAclsController < ActionController::Base
|
|
2
|
+
skip_before_action :verify_authenticity_token
|
|
3
|
+
def show
|
|
4
|
+
@object = params[:id].camelize.constantize
|
|
5
|
+
@acls = Acl.where(object_type: @object.name).all
|
|
6
|
+
@rules = rules
|
|
7
|
+
render inline: ERB.new(File.open("/#{__FILE__.split('controllers').first}views/index.erb").read).result(binding), type: 'text/html'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set
|
|
11
|
+
@acl = Acl.where(params.require(:acl).permit(:object_type, :user_type, :state, :action, :user_id)).first
|
|
12
|
+
if @acl.present?
|
|
13
|
+
Acl.destroy(@acl.id)
|
|
14
|
+
else
|
|
15
|
+
@acl = Acl.create(params.require(:acl).permit(:object_type, :user_type, :state, :action, :user_id))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
@object = params[:acl][:object_type].camelize.constantize
|
|
19
|
+
@acls = Acl.where(object_type: @object.name).all
|
|
20
|
+
|
|
21
|
+
render inline: rules
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def rules
|
|
27
|
+
@rules = @acls.sort_by(&:user_type).map{|acl| "#{acl.user_type} can #{acl.action} #{acl.state} #{acl.object_type}"}.join('</br>')
|
|
28
|
+
@rules = @rules.blank? ? 'Good, nobody is permitted to do anything' : @rules
|
|
29
|
+
end
|
|
30
|
+
end
|
data/dynamic_acl.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "dynamic_acl"
|
|
3
|
+
s.version = "0.1.0"
|
|
4
|
+
|
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
6
|
+
s.require_paths = ["lib"]
|
|
7
|
+
s.authors = ["Dileep Nandanam"]
|
|
8
|
+
s.date = "2014-11-20"
|
|
9
|
+
s.description = "gem for Dynamic access controll with editable access controll matrix in web view"
|
|
10
|
+
s.email = "dileepsnandanam@gmail.com"
|
|
11
|
+
s.extra_rdoc_files = [
|
|
12
|
+
"LICENSE.txt"
|
|
13
|
+
]
|
|
14
|
+
s.files = [
|
|
15
|
+
"Gemfile",
|
|
16
|
+
"Gemfile.lock",
|
|
17
|
+
"LICENSE.txt",
|
|
18
|
+
"VERSION",
|
|
19
|
+
"lib/dynamic_acl/engine.rb",
|
|
20
|
+
"lib/dynamic_acl/engine.rb",
|
|
21
|
+
"app/controllers/dynamic_acls_controller.rb",
|
|
22
|
+
"lib/tasks/install.rake",
|
|
23
|
+
"lib/dynamic_acl.rb",
|
|
24
|
+
"dynamic_acl.gemspec"
|
|
25
|
+
]
|
|
26
|
+
s.homepage = "http://github.com/dileepnandanam/dynamic_acl"
|
|
27
|
+
s.licenses = ["MIT"]
|
|
28
|
+
s.rubygems_version = "2.2.2"
|
|
29
|
+
s.summary = "Use dynamic_acl with rails active_record"
|
|
30
|
+
end
|
|
31
|
+
|
data/lib/dynamic_acl.rb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module DynamicAcl
|
|
2
|
+
class Engine < ::Rails::Engine
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
def self.can?(record, action, object, user_id=nil)
|
|
6
|
+
::Acl.where(user_type: record.user_type, user_id: user_id, action: action, object_type: object.class.name, state: object.state).first.present?
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
namespace :dynamic_acl do
|
|
2
|
+
desc "Create migratio for acls"
|
|
3
|
+
task :install do
|
|
4
|
+
content = File.open('config/routes.rb').read
|
|
5
|
+
lines = content.split("\n")
|
|
6
|
+
ends_at = lines.enum_for(:each_with_index).select{|line, index| line.include?('end')}.last.last
|
|
7
|
+
lines[ends_at] = %{
|
|
8
|
+
resources :dynamic_acls do
|
|
9
|
+
put :set, on: :collection
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
File.open('config/routes.rb', 'w') do |f|
|
|
15
|
+
f.puts lines.join("\n")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
File.open("db/migrate/#{Time.now.to_s.gsub!(/[-\s:]/, '')}_create_acl.rb", 'w') do |f|
|
|
19
|
+
f.puts %{
|
|
20
|
+
class CreateAcl < ActiveRecord::Migration[5.2]
|
|
21
|
+
def change
|
|
22
|
+
create_table :acls do |t|
|
|
23
|
+
t.integer :user_id
|
|
24
|
+
t.string :user_type
|
|
25
|
+
t.string :action
|
|
26
|
+
t.string :state
|
|
27
|
+
t.string :object_type
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
system("rake db:migrate")
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: dynamic_acl
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Dileep Nandanam
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: gem for Dynamic access controll with editable access controll matrix
|
|
14
|
+
in web view
|
|
15
|
+
email: dileepsnandanam@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files:
|
|
19
|
+
- LICENSE.txt
|
|
20
|
+
files:
|
|
21
|
+
- Gemfile
|
|
22
|
+
- Gemfile.lock
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- VERSION
|
|
25
|
+
- app/controllers/dynamic_acls_controller.rb
|
|
26
|
+
- dynamic_acl.gemspec
|
|
27
|
+
- lib/dynamic_acl.rb
|
|
28
|
+
- lib/dynamic_acl/engine.rb
|
|
29
|
+
- lib/tasks/install.rake
|
|
30
|
+
homepage: http://github.com/dileepnandanam/dynamic_acl
|
|
31
|
+
licenses:
|
|
32
|
+
- MIT
|
|
33
|
+
metadata: {}
|
|
34
|
+
post_install_message:
|
|
35
|
+
rdoc_options: []
|
|
36
|
+
require_paths:
|
|
37
|
+
- lib
|
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
requirements: []
|
|
49
|
+
rubyforge_project:
|
|
50
|
+
rubygems_version: 2.5.2
|
|
51
|
+
signing_key:
|
|
52
|
+
specification_version: 4
|
|
53
|
+
summary: Use dynamic_acl with rails active_record
|
|
54
|
+
test_files: []
|